我有ToolStripMenuItem
,当我运行应用程序时,它看起来像这样:
如您所见,ToolStripMenuItem
左侧有一些小空格。
如何删除它?我试图编辑每个房产,但它仍然是......
提前谢谢大家!
答案 0 :(得分:4)
要更改菜单项的外观,您应使用自定义ToolStripProfessionalRenderer
ProfessionalColorTable
。
要更改该颜色,您应该覆盖自定义颜色表的ImageMarginGradientBegin
属性并返回所需的颜色。
例如,您可以:
public class CustomColorTable : ProfessionalColorTable
{
public override Color ImageMarginGradientBegin
{
get { return Color.Red; }
}
public override Color ImageMarginGradientMiddle
{
get { return Color.Green; }
}
public override Color ImageMarginGradientEnd
{
get { return Color.Blue; }
}
public override Color ToolStripDropDownBackground
{
get { return Color.Yellow; }
}
public override Color MenuItemSelected
{
get { return Color.Pink; }
}
//You should also override other properties if you need.
//This is just a sample code to show you the solution
}
然后在你的表单中加载:
private void Form_Load(object sender, EventArgs e)
{
ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new CustomColorTable());
}