Right Clicking Listbox with select

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I'm able to add a context menu to the right click on a listbox but it
does not select the item in the listbox. I would like the context
menu before it pops up to select the item that the mouse was over when
the right click occurred. Is this possible?

Thanks,
Cristov
 
Check out the ListBox's IndexFromPoint function, you can use this to set the
selected item when a right-click occurs.

- Pete
 
AirPete said:
Check out the ListBox's IndexFromPoint function, you can use this to set the
selected item when a right-click occurs.

- Pete

Pete,

Thanks for the info. It worked great with my listbox. Now I'm having
the same problem with a listview though and it doesn't support the
IndexFromPoint method. Any ideas?

Thanks,
Cristov
 
"AirPete" <[email protected]> wrote in message
Pete,

Thanks for the info. It worked great with my listbox. Now I'm having
the same problem with a listview though and it doesn't support the
IndexFromPoint method. Any ideas?

Thanks,
Cristov

Cristov,

I just tried a ListView, and it seemed to seelct on rightclick anyway.
Are you manually showing the ContextMenu on the right Click event, or using
the ContextMenu property?
Mine was set to Activation = Standard and ContextMenu = my contextmenu, with
only an ItemActivate event handler.

However, the GetItemAt method is the ListView's equivilent.

- Pete
 
Back
Top