Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting from listbox with right mouse button

Status
Not open for further replies.

kyledunn

Programmer
Jan 2, 2001
145
US
Hey guys,

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
 
Just curious: why would you want the right mouse button to allow this Kyle? ONE mouse button to select an item isn't enough?!
;)

Jack
 
I need to use the second button for a backup. ;) Actually, the user selects an item from the list box of a custom user control combo box with the left mouse button. I want the right mouse button to select and trigger an option to delete the selected item from the listbox. At the moment it will only delete an item that has been selected prior to clicking the right mouse button. So much for this feature if I can't learn to select with the right mouse button.

Kyle

 
Hey Jack,

I solved this by adding the listbox.TopIndex with the Y mouse position divided by the selected item's height. This gave me the item that was clicked by the right mouse button so I could assign the SelectedIndex. Right click deleting is now a feature in my custom combo box. I'm happy.

Kyle

 
Sweet! Man, you get the IT-Pro award for the month figuring that one out!
:)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top