圆角PICTUREBOX

gui41021 gui41021 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
新手求指点

WINFORM下 想画一个圆角PICTUREBOX

用的代码:

//圆角pic
public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

gp.CloseFigure();

g.DrawPath(p, gp);
gp.Dispose();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
DrawRoundRect(e.Graphics, Pens.Black, 0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1, 10);
}
效果图:

矩形画出来了 图片还是方的

引用
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

请问如何修改?多谢
...全文

相关推荐

C# WinForm PictureBox 添加圆角

为PictureBox 添加圆角,圆角的大小可以自己定义,可以在VS上直接配置.

qq_34730343

winform圆角框和窗体最大化问题

大家注释104行至108行的OnResize方法运行,此时窗口最大化时logo图片在中间,当解注释后再执行,此时窗口最大化时logo不居中,而居左,求解释

swx002

Winform窗体圆角设计代码

网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角。主要运用了System.Drawing.Drawing2D。 效果图 代码如下 private void BeautiLoginForm_Paint(object sender, PaintEventArgs e) { Type(this, 25, 0.1); } private void Type(Control sender, int p_1, double p_2) { GraphicsPath oPath = new GraphicsPath(); o

weixin_38691739

C#圆角窗体简单实现方法

本文实例讲述了C#圆角窗体简单实现方法。分享给大家供大家参考。具体如下: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Resize(object sender, EventArgs e) { Type(this, 25, 0.1); } private void Type(Control sender, int p_1, double p_2) { GraphicsPath oPath = ne

weixin_38736529

VB矢量绘图程序实例.7z

这是一款开源的完整矢量绘图控件源码,或者说是这个控件的一个典型应用,通过这个控件你可以画直线、弧线、矩形、圆角矩形、多边形、文本和图片等,而且还支持旋转、缩放、选择、排列等操作,功能还是不错的!

qq_38220914
评论 9
收藏 已收藏
分享
返回顶部
gui41021
C# 111,130 成员 642,539 内容