Some people are just never satisfied, are they?
Oh well...I tried to select items from a listbox using the right mouse button, namely through the mousedown event again, but there seems to be no way to tell the listbox to make the item under the mouse the selected item...in fact, listboxes don't seem to have any concept of selected items, which is most likely to do with the items in a listbox not being discrete objects...which makes things tricky.
So, at the risk of being berated for this, I'm going to say that it's very unlikely that you can select items from a listbox using the right mouse button.
But, helpful chap that I am, here's a solution:
From the microsoft windows common controls 6.0 SP3 tab, select the ListView control and put it in place of yourListBox control. ListViews are fully object oriented and are really just a visual collection of sorts, where each item in the list is an object in its own right, which gives you stupendous amounts of flexibility, plus, by default, left or right clicking on an item will make that item the SelectedItem of the ListView control. So, do something like this:
Private Sub Form_Load()
Dim itm As MSComctlLib.ListItem
For a = 1 To 9
Set itm = ListView1.ListItems.Add(a, , "Item " & a)
Next
End Sub
Private Sub ListView1_Click()
Me.Text1.Text = Me.ListView1.SelectedItem
End Sub
In this little test app, I've got a listview control called ListView1 and a textbox control called (go on, guess) Text1. As you can see, as each item in the listview control is an object (a list item object), you have to set an object up and then add it to the listview control by using the controls Add method. In the stuff above, ten items will be added, called "item 1" to "item 9". Then, on the click event of the listview control, I've just set the textbox control to show the SelectedItem (in fact, the SelectedItem is, in itself, a list item and has all the properties and methods of a list item...it just happens that the default property for a list item is text, so effectively, what I'm doing here is going:
me.text1.text = selecteditem.text
but you don't have to know that if you're not interested).
So there you go.
Shun not the ListView control, for, verily, it is the best thing since processed cheese.
Here endeth my posting.
Paul
