How to remove MenuStrip submenu margins?
Asked Answered
Z

1

19

Do you know how to remove margin (probably the one for image and check box on the left and right) of the submenu in MenuStri? In MSDN article there is explained how to remove it from context menus. It is written that I should do it the same way in MenuStrip but MenuStrip do not have ShowImageMargin nor ShowCheckMargin. Maybe I'm missing something. Can you help?

Ziagos answered 12/5, 2009 at 17:19 Comment(1)
Are you not using images in your menustrip or do you want to display the margin only if the submenu contains a check or image?Suggest
O
40

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;
Ogilvie answered 7/12, 2009 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.