Jump to content

ListBox select item by right-clicking

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Here is how to select an item in a listbox when right-clicking:

C++

private: System::Void listBox1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {

          if (e->Button == System::Windows::Forms::MouseButtons::Right) {

          listBox1->SelectedIndex = listBox1->IndexFromPoint(e->X, e->Y);

 }

					

			 }

C#

private void LST_BX_MouseDown(object sender, MouseEventArgs e) {

   if(e.Button == MouseButtons.Right)

      LST_BX.SelectedIndex = LST_BX.IndexFromPoint(e.X, e.Y);

}



#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
Nice code. I've never really thought about right-clicking and selecting. It seems like a feature that should already be imbedded int he code.

#3
Void

Void

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 411 posts
You would think this would be default code.....
Void