带有实心边框的 C# winforms 按钮,如 3d [英] C# winforms button with solid border, like 3d
本文介绍了带有实心边框的 C# winforms 按钮,如 3d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 C# winforms 上创建带有实心边框(3d)的按钮,如下图所示?
Panel BorderStyle
可以设置为Fixed3D
,但是按钮BorderStyle
不能设置为Fixed3D
.
我也已经尝试过 FlatAppearance
这实际上是平面样式.
解决方案
您可以通过这种方式自定义 Button
控件具有粗 3d 边框:
- 设置按钮
FlatStyle
为Flat
- 在
FlatApperanace
中设置BorderSize
为0
- 在
FlatApperanace
中将MouseOverBackColor
设置为ControlLight
然后处理 Paint
事件并使用
How can I create button with solid border(3d), like picture below on C# winforms?
Panel BorderStyle
can be set as Fixed3D
, but buttons BorderStyle
cannot be set as Fixed3D
.
I also already tried FlatAppearance
which is actualy flat style.
解决方案
You can customize the Button
control this way have thick 3d borders:
- Set the Button
FlatStyle
to beFlat
- In the
FlatApperanace
setBorderSize
to0
- In the
FlatApperanace
setMouseOverBackColor
toControlLight
Then handle Paint
event and using ControlPaint.DrawBorder
draw a thick 3d border:
private void button1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, button1.ClientRectangle,
SystemColors.ControlLightLight, 5, ButtonBorderStyle.Outset,
SystemColors.ControlLightLight, 5, ButtonBorderStyle.Outset,
SystemColors.ControlLightLight, 5, ButtonBorderStyle.Outset,
SystemColors.ControlLightLight, 5, ButtonBorderStyle.Outset);
}
And here is the result:
这篇关于带有实心边框的 C# winforms 按钮,如 3d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文