winform C# 怎么在背景图上面用Gdi画出圆角矩形边框

qq_29783739 2015-09-01 11:50:11
如图
...全文
184 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
bdmh 2015-09-01
圆角需要你自己绘制,四条直线,不要画到头,留一点地方绘制圆弧,函数都是有的
回复
qq_29783739 2015-09-01
private GraphicsPath RoundRect(Rectangle r, int round) { GraphicsPath gp = new GraphicsPath(); r.Width = r.Width - 1; r.Height = r.Height - 1; int x = r.X; int y = r.Y; int w = r.Width; int h = r.Height; gp.AddArc(x, y, round, round, 180, 90); gp.AddArc(w - round, y, round, round, 270, 90); gp.AddArc(w - round, h - round, round, round, 0, 90); gp.AddArc(x, h - round, round, round, 90, 90); gp.CloseAllFigures(); return gp; } public void huaxian() //绘线条 { Bitmap im = (Bitmap)this.panel1.BackgroundImage; Graphics mygraphics = Graphics.FromImage(im); Pen mypen = new Pen(Color.Black, 5); mygraphics.DrawPath(new Pen(Color.Black, 5), RoundRect(this.panel1.ClientRectangle, 50)); mygraphics.Dispose(); this.panel1.BackgroundImageLayout = ImageLayout.Tile; this.panel1.BackgroundImage = im; } private void button1_Click(object sender, EventArgs e) { huaxian(); } 这是我写的方法为什么没效果呢
回复
相关推荐
发帖
组件/控件开发
创建于2007-09-28

8838

社区成员

.NET技术 组件/控件开发
申请成为版主
帖子事件
创建了帖子
2015-09-01 11:50
社区公告
暂无公告