How to remove MenuStrip submenu margins?

柔情痞子 提交于 2019-12-03 22:55:00
SLA80

Very similar, but instead of using "ContextMenuStrip" (which is used in your MSDN article), you have to use "ToolStripDropDownMenu". This way:

((ToolStripDropDownMenu)noMargins.DropDown).ShowImageMargin = false;

For example, if you want to remove all image margins from your menubar called "menuStrip1", add this code to your form initialization routine:

// Removing image margins (space for icons on left) from menubar items:
foreach (ToolStripMenuItem menuItem in menuStrip1.Items)
    ((ToolStripDropDownMenu)menuItem.DropDown).ShowImageMargin = false;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!