Selecting from listbox with right mouse button
-
If you left click on a line item in a listbox it selects the item. Clicking the right mouse button is detectable in the listbox but does not select the item. Is there a way to override this listbox behaviour and select an item with the right mouse button? Kyle
-
If you left click on a line item in a listbox it selects the item. Clicking the right mouse button is detectable in the listbox but does not select the item. Is there a way to override this listbox behaviour and select an item with the right mouse button? Kyle
override the MouseDown Event from the ListBox Control: private void listBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button != MouseButtons.Right) return; int nIndex = listBox.IndexFromPoint(new Point(e.X,e.Y)); if(nIndex != -1) listBox.SetSelected(nIndex,true); } Rgrds Martin