|
-
Aug 30th, 2009, 09:48 PM
#1
Thread Starter
Lively Member
[RESOLVED] Assign context menu strip to listbox item?
How can I assign a context menu strip to a listbox item and not the listbox itself?
-
Aug 30th, 2009, 09:59 PM
#2
Re: Assign context menu strip to listbox item?
You can't. You can only associate a ContextMenuStrip with a control and the individual items in the ListBox are not controls.
What you would have to do is detect a right-click on the ListBox yourself, determine what item is under the mouse pointer and then call Show on the appropriate ContextMenuStrip.
Towards that end, you would:
1. Handle the MouseClick event.
2. Test for the right mouse button.
3. Call GetItemRectangle method for each item.
4. Test which item contains the location that was clicked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|