C# 如何绘制圆角按钮

rui90102 2011-09-13 02:12:21
如题
...全文
830 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
rui90102 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 mfc10001003 的回复:]

就是画个圆角矩形,上面文字,点一下改个颜色。

---------------------
虚拟仪表控件 www.beaugauge.net
[/Quote]

还没有找到解决办法啊,求帮助
tommir3 2011-09-13
  • 打赏
  • 举报
回复
做一个按钮控件,
你是想画出来,或者用图片,
都随你。
wangs_1 2011-09-13
  • 打赏
  • 举报
回复
在button的Paint事件下写。将pnl改成你button的名字
白鸽 2011-09-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wangs_1 的回复:]

C# code
e.Graphics.Clear(pnl.BackColor);



Rectangle Rtg_LT = new Rectangle();

Rectangle Rtg_RT = new Rectangle();

Rectangle Rtg_LB = new Rectangl……
[/Quote]
你这个是Silverlight中的吧,其实楼主完全没必要重绘或者做一个原型的控件,你可以做几张一样的图片只是颜色不同,然后在根据按钮的事件来给按钮判断付哪张图片,将按钮的边框背景设置成透明的就OK了
Dotar 2011-09-13
  • 打赏
  • 举报
回复
我觉得还不如做个图片当按钮,效果更好
rui90102 2011-09-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wangs_1 的回复:]

直接套用看行不行,不行的话,在稍微改动一下就行了
[/Quote]


不行呢,好多属性都没有,555 windows mobile
rui90102 2011-09-13
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wangs_1 的回复:]

直接套用看行不行,不行的话,在稍微改动一下就行了
[/Quote]

好的,我试试,谢谢了
wangs_1 2011-09-13
  • 打赏
  • 举报
回复
直接套用看行不行,不行的话,在稍微改动一下就行了
wangs_1 2011-09-13
  • 打赏
  • 举报
回复
e.Graphics.Clear(pnl.BackColor);  



Rectangle Rtg_LT = new Rectangle();

Rectangle Rtg_RT = new Rectangle();

Rectangle Rtg_LB = new Rectangle();

Rectangle Rtg_RB = new Rectangle();

Rtg_LT.X = 0; Rtg_LT.Y = 7; Rtg_LT.Width = 10; Rtg_LT.Height = 10;

Rtg_RT.X = e.ClipRectangle.Width - 11; Rtg_RT.Y = 7; Rtg_RT.Width = 10; Rtg_RT.Height = 10;

Rtg_LB.X = 0; Rtg_LB.Y = e.ClipRectangle.Height - 11; Rtg_LB.Width = 10; Rtg_LB.Height = 10;

Rtg_RB.X = e.ClipRectangle.Width - 11; Rtg_RB.Y = e.ClipRectangle.Height - 11; Rtg_RB.Width = 10; Rtg_RB.Height = 10;



Color color = Color.FromArgb(51, 94, 168);

Pen Pen_AL = new Pen(color, 1);

Pen_AL.Color = color;

Brush brush = new HatchBrush(HatchStyle.Divot, color);



e.Graphics.DrawString(pnl.Text, pnl.Font, brush, 6, 0);

e.Graphics.DrawArc(Pen_AL, Rtg_LT, 180, 90);

e.Graphics.DrawArc(Pen_AL, Rtg_RT, 270, 90);

e.Graphics.DrawArc(Pen_AL, Rtg_LB, 90, 90);

e.Graphics.DrawArc(Pen_AL, Rtg_RB, 0, 90);

e.Graphics.DrawLine(Pen_AL, 5, 7, 6, 7);

e.Graphics.DrawLine(Pen_AL, e.Graphics.MeasureString(pnl.Text, pnl.Font).Width + 3, 7, e.ClipRectangle.Width - 7, 7);

e.Graphics.DrawLine(Pen_AL, 0, 13, 0, e.ClipRectangle.Height - 7);

e.Graphics.DrawLine(Pen_AL, 6, e.ClipRectangle.Height - 1, e.ClipRectangle.Width - 7, e.ClipRectangle.Height - 1);

e.Graphics.DrawLine(Pen_AL, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 7, e.ClipRectangle.Width - 1, 13);

110,549

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧