Question

What is the best method of using native menus in C#?

Edit: I want to use the native menu because it's better looking than the ugly .NET menu. Can someone explain to me exactly how I can use it?

Was it helpful?

Solution

In the System.Windows.Forms namespace, you'll find the classes: Menu, ContextMenu, MenuItem, MenuStrip, ContextMenuStrip, ToolBar, ToolStrip, and others.

These classes are simply wrappers around the Win32 API calls that implement these controls natively. The same is true for nearly every class in the System.Windows.Forms namespace; when you use these classes, you're actually using the native controls.

So the best method of using native menus in .NET is to use the controls .NET provides for to display menus, as mentioned above. Whichever ones you use depends on what you're trying to accomplish. The simplest option for attaching a main menu to a form is using the Menu object, populated with a MenuItem set.

OTHER TIPS

If you are referring to the System Menu (the context menu that pops up when right-clicking on a window's title bar), here is a great article on CodeGuru for manipulating it in C#.

You can't get it w/o a bunch of API hacking. Besides, you can get a better menu easier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top