Using a Windows 7 style menustrip in Windows Forms [duplicate]

旧城冷巷雨未停 提交于 2019-11-28 04:39:28

问题


Possible Duplicate:
Standard Windows menu bars in Windows Forms

I am using windows forms and when I use a MenuStrip item, I get something that looks like this:

http://imgkk.com/i/ggn1.png

Is it possible to use menu strips like the ones the system uses, like in Windows Explorer, or Firefox, for example:

http://imgkk.com/i/cxyg.png

with Windows Forms, or C# in general?


回答1:


Try using a MainMenu instead of a MenuStrip. The MainMenu will pick up the underlying operating system's current style, whereas the MenuStrip does not. Even though MainMenu was replaced with MenuStrip, it is still supported going forwards (according to the MSDN docs).

MenuStrip is rendered entirely in C# and does not use the current operating system's styles, whereas the MainMenu control renders using the underlying OS API and does.

MainMenu might not be in your toolbox. To add it, right click in the toolbox, select "Choose Items..." and then make sure the MainMenu item is checked.

This article explains the differences between MainMenu and MenuStrip in more depth.




回答2:


An alternative is to use a custom tool strip renderer,

http://code.google.com/p/szotar/source/browse/trunk/Client/Szotar.WindowsForms/Base/NativeToolStripRenderer.cs



来源:https://stackoverflow.com/questions/2946241/using-a-windows-7-style-menustrip-in-windows-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!