• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

画上picturebox1的油漆

用户头像
it1352
帮助1

问题说明

你好,我想当我点击button1在picturebox1的油漆上画一个椭圆。

hello, i want when i click on button1 draw a ellipse on paint of picturebox1.

正确答案

#1
你可以做到,但它只是做得很少甚至没有意义。这与绘制位图相同,但有额外的麻烦,不会给你带来任何好处。做这样的事情很容易,只是不使用 PictureBox ,它没有这样的目的,只有在需要静态图像时才有用。请查看我过去的答案:

在其中附加图片图片框 [ ^ ],

画一个矩形C# [ ^ ],

如何从旧图纸中清除面板 [ ^ ]。



参见:

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

在面板上捕获绘图 [ ^ ],

mdi子表单之间的绘制线 [ ^ ]。



-SA
You can do it, but it simply makes little to no sense. This is the same as drawing on a bitmap, but with extra hassles which won't give you anything good. Doing such thing is easy enough, only don't use PictureBox, it does not have such purpose, only helpful if you need static images. Please see my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^].

See also:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^].

—SA
处理Paint事件,并在提供的Graphics对象上绘制一个椭圆:



Handle the Paint event, and draw an ellipse on the supplied Graphics object:

private bool drawIt = false;
private void myButton_Click(object sender, EventArgs e)
    {
    drawIt = !drawIt;
    myPictureBox.Invalidate();
    }

private void myPictureBox_Paint(object sender, PaintEventArgs e)
    {
    if (drawIt)
        {
        e.Graphics.DrawEllipse(Pens.Red, 10, 10, myPictureBox.Width - 20, myPictureBox.Height - 20);
        }
    }

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgabbe
系列文章
更多 icon
同类精品
更多 icon
继续加载