2

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?

sooprise
  • 22,657
  • 67
  • 188
  • 276

2 Answers2

2
contextMenuStrip1.BackColor = Color.Pink;

Put that in the onLoad handler, or go to the properties and change the BackColor there :o)

OdinX
  • 4,135
  • 1
  • 24
  • 33
  • 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. – sooprise Jun 15 '10 at 21:28
  • 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 Jun 15 '10 at 21:35
2

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.

Community
  • 1
  • 1
adrianbanks
  • 81,306
  • 22
  • 176
  • 206
  • I'm using Visual C# 2008, and ContextMenuStrip is the only option in the toolbox (ContextMenu doesn't seem to be there) – sooprise Jun 15 '10 at 21:38
  • @Soo: If you read my answer linked above, it tells you how to add `ContextMenu` into the toolbox. – adrianbanks Jun 15 '10 at 21:40
  • 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. – Sean Hanley Jun 16 '10 at 03:58