Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a custom control which is contained in a context menu strip. So when I click a button, the context menu strip displays my control just like any other menu item.

The control has 10 checkboxes on it but is used as only a single menu item. I have been trying to duplicate the light blue highlight rectangle that a normal menu displays when hovering over a menu item but can't find any examples of how to accomplish it.

Does anyone already know how to do this or what the proper search term would be in google? Any help would be appreciated and thanks!

Mark

I am using vb.net and the framework 4 if that helps...
Posted
Comments
Sergey Alexandrovich Kryukov 13-May-12 23:32pm    
Not clear. What control is used as a single menu item and why? Why duplicating anything? What's the problem? Why would you need an example if MSDN help page on the control explains everything?
--SA
Mark Regal 13-May-12 23:51pm    
I'm not sure why this is a difficult question. See if you understand this...

One user control (inheriting user control)
Ten checkboxes on the user control and nothing else
The user control is accessed via a ToolStripControlHost
The ToolStripControlHost is then wrapped into a context menu strip
Click on a button and the context menu appears with a single menu item
The single menu item is the user control with 10 checkboxes on it

Everything works fine and as expected to this point. I just am not sure how to hightlight each checkbox individually with the normal menu item selection highlighter.

If you don't know what that is then run one of your projects that has a menustrip and some items in it. Then highlight one of the menu items with a mouse over and you'll see this cool looking blue gradient rectangle that shows which menu item that you're currently over.

Now that's what I'd like to duplicate if I have too. I don't want to and if you know of another way to get the selection rectangle then do tell! You're making this sound academic and I really hope it is :)

What is the msdn article which you're referring to? Do you happen to have the address of it? So now that you understand this a little better, what would you suggest? Please advise and thanks!








Sergey Alexandrovich Kryukov 14-May-12 15:16pm    
I'm sure the question is not difficult, meaning required functionality. Your question is just difficult to understand. You just skip the goal of this activity and go straight to showing of a rectangle. Why standard menu behavior does not work for you? MSDN article is: type fully-qualified menu class name (which you did not share with us; maybe you were unaware, but there is more then one) in Google and you will see. MSDN help page -- it explains everything.
--SA
Mark Regal 15-May-12 0:06am    
Hey SA...just wanted to say that first :)

So I think it might be more productive to take the menustrip out of the equation here. Maybe just think along the lines of creating a selection rectangle that you can create over a control so you can see the control underneath it.

So when your mouse is over the control it appears, when your mouse is not over the control it disappears. So how do you create a semi-transparent rectangle that you can see a control through.

Does that make sense?



Sergey Alexandrovich Kryukov 17-May-12 16:15pm    
Did you think about population of the menu strip before it's shown, every time? It is usually easy to do.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900