Bel*_*fed 3 c# designer properties toolstrip winforms
我有我的ToolStripMenuItem,当我运行应用程序时,它看起来像这样:
如您所见,ToolStripMenuItem左侧有一点空白。
我怎样才能删除它?我试图编辑每个属性,但它仍然存在......
谢谢大家!
要更改菜单项的外观,您应该使用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
}
Run Code Online (Sandbox Code Playgroud)
然后在您的表单中加载:
private void Form_Load(object sender, EventArgs e)
{
ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new CustomColorTable());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
788 次 |
| 最近记录: |