Right click to selct item in a Listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to select an item ina listbox with the right click event?
basically I want a user to be able to rightclick an item which will select
the item and then bring up the context menu which has a delete option in it.

As it stands if I select an item and then rightclick a seperate item
selecting delete will remove the selected item instead of the one that was
right clicked

Cheers
Niels
 
Hi,
One way is to handle the MouseDown event of the list box:

If (e.Button = MouseButtons.Right) Then
ListBox.SelectedIndex = ListBox.IndexFromPoint (e.X, e.Y)
End If

HTH

Is there a way to select an item ina listbox with the right click event?
basically I want a user to be able to rightclick an item which will select
the item and then bring up the context menu which has a delete option in it.

As it stands if I select an item and then rightclick a seperate item
selecting delete will remove the selected item instead of the one that was
right clicked

Cheers
Niels
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top