Right Clicking Listbox with select

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
 
A

AirPete

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

- Pete
 
C

Chris

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
 
A

AirPete

"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
 

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

Top