18

您知道如何删除 MenuStri 中子菜单的边距(可能是左右图像和复选框的边距)吗?在MSDN 文章中,解释了如何从上下文菜单中删除它。据说我应该在 MenuStrip 中以相同的方式执行此操作,但 MenuStrip 没有 ShowImageMargin 或 ShowCheckMargin。也许我错过了一些东西。你能帮我吗?

4

1 回答 1

37

非常相似,但不是使用“ContextMenuStrip”(在您的MSDN 文章中使用),您必须使用“ ToolStripDropDownMenu ”。这边走:

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

例如,如果您想从名为“menuStrip1”的菜单栏中删除所有图像边距,请将以下代码添加到表单初始化例程中:

// Removing image margins (space for icons on left) from menubar items:
foreach (ToolStripMenuItem menuItem in menuStrip1.Items)
    ((ToolStripDropDownMenu)menuItem.DropDown).ShowImageMargin = false;
于 2009-12-07T15:32:35.437 回答