如何使用GDI+在picturebox控件上面绘画

萨鲁-梅路艾姆 2012-04-06 10:29:23
比如,在picturebox控件上画个矩形。
...全文
329 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tsmoon2009 2012-04-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
C# code


private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, 0, 0, 100, 100);

}
[/Quote]

e.Graphics.FillRectangle(Brushes.Red, x, y, width, height);

x,y对应矩形左上角坐标 width, height宽跟高

创建Graphics对象在控件或窗体上还可以
Graphics g=this.picturebox.CreatGraphics();
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

C# code

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, 0, 0, 100, 100);

}
[/Quote]
如果我想自定义坐标和大小呢?
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

C# code

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, 0, 0, 100, 100);

}
[/Quote]

如果我想自定义坐标呢?
bdmh 2012-04-06
  • 打赏
  • 举报
回复

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, 0, 0, 100, 100);

}

110,571

社区成员

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

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

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