Context menus seem to have a default white background.
This looks pretty nice, but for consistency's sake, I'd like the context menu to be gray like with any other application. How can I get this style for my context menu?
views:
66answers:
2
+1
A:
contextMenuStrip1.BackColor = Color.Pink;
Put that in the onLoad handler, or go to the properties and change the BackColor there :o)
Chief17
2010-06-15 21:26:22
Ok, cool! but... the context menu is flat, and the other ones appear to have depth. I just want my context menu to look the same as all the others.
Soo
2010-06-15 21:28:09
By explicitly setting a background colour, you are forcing a user to have this colour, even if they change their Windows styles to something different.
adrianbanks
2010-06-15 21:35:10
+2
A:
Have a look at my answer for another similar question about menu items.
What you need to do is to use a ContextMenu
instead of a ContextMenuStrip
. This will pick up the default colours (ie. gray) and styles set in the underlying operating system instead of its own defined colours and styles.
adrianbanks
2010-06-15 21:32:49
I'm using Visual C# 2008, and ContextMenuStrip is the only option in the toolbox (ContextMenu doesn't seem to be there)
Soo
2010-06-15 21:38:08
@Soo: If you read my answer linked above, it tells you how to add `ContextMenu` into the toolbox.
adrianbanks
2010-06-15 21:40:31
While automatically getting the default OS colors and appearance for menus is why I always opt for the (technically) older ContextMenu, it doesn't easily support image icons out of the box. I've used [this](http://wyday.com/blog/2008/vista-menu-with-icons-in-c-sharp/) quite successfully in the past to do just that, though.
Yadyn
2010-06-16 03:58:05