我有一个ToolStrip的在我设置背景颜色为透明C#应用程序。这揭示了潜在的窗体的颜色,但不幸的是,ToolStrip的边框仍然可见。
我已经实现了一个自定义呈现,并覆盖了DrawBoarder方法不画任何东西,但似乎适用于所有的包含按钮以及(即还绘制没有边框的下拉按钮,在菜单中)。
所以,我坚持。什么是绘制透明的整个ToolStrip的,但先不谈按钮的最佳方法是什么?
解决方案 保护覆盖无效OnRenderToolStripBorder(ToolStri prenderEventArgs E)
{
如果(e.ToolStrip.GetType()。名称!=MyCustomToolStrip)
{
base.OnRenderToolStripBorder(E);
}
}
I have a ToolStrip in a C# application that I set the background color to Transparent. This reveals the underlying form's color but unfortunately the ToolStrip border is still visible.
I've implemented a Custom Renderer and overridden the DrawBoarder method to not draw anything but that seems to apply to all of the contained buttons as well (i.e the menu on drop down buttons are also drawn without a border).
So I'm stuck. What's the best way to draw transparent the entire ToolStrip but leave the buttons alone?
解决方案protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
if( e.ToolStrip.GetType().Name != "MyCustomToolStrip" )
{
base.OnRenderToolStripBorder(e);
}
}
上一篇:ClassCastException异常:的java.lang.Object []不能转换为java.lang.String []机器人转换为、机器人、异常、java
下一篇:设置键和值的微调