请问为什么最小化后picturebox上画的图就没了?

thankuu 2003-07-30 09:07:47
我通过以下在picturebox上画线,最小化然后再最大化,原来画的线条就没有了,请问为什么?

PictureBox1.CreateGraphics.DrawLine(New Pen(Color.Black, 1), oldpt, newpt)
...全文
355 13 打赏 收藏 举报
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
brightheroes 2003-08-02
  • 打赏
  • 举报
回复
写在paint事件中,每当窗体重绘时就会自动调用
swpilogging 2003-08-01
  • 打赏
  • 举报
回复
在程序代码中自己用几句调用picturebox 的 paint事件
用路径,区域来存取你画的线什么的
烤火的鱼 2003-08-01
  • 打赏
  • 举报
回复
在onpaint事件中写代码。
shixueli 2003-08-01
  • 打赏
  • 举报
回复
需要重划
lijiangchxp 2003-08-01
  • 打赏
  • 举报
回复
写在 Paint 事件里,否则窗口遮盖或是最小化后图形就会消失;
raulredondo 2003-07-31
  • 打赏
  • 举报
回复
在MouseMove事件里面记录每一个点的位置,存储在一个数组里面,然后在Paint事件里面根据每一个点的位置重新画一遍。
PictureBox1_MouseMove()
{
Points[i] = new Point(e.X, E.y);
i++;
}

PictureBox1_Paint()
{
for(int i = 0; i < Max; i++)
PictureBox1.CreateGraphics.DrawLine(New Pen(Color.Black, 1), Points[i], Points[i+1]);
}
thankuu 2003-07-31
  • 打赏
  • 举报
回复
up
thankuu 2003-07-30
  • 打赏
  • 举报
回复
raulredondo(),我这个是画mouse轨迹的,就是以下:

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
'THIS routine does draw an expanding dashed rectangle correctly

If startDrawing = 1 Then

newpt = New Point(e.X, e.Y)

PictureBox1.CreateGraphics.DrawLine(New Pen(Color.Black, 1), oldpt, newpt)

oldpt = newpt
ok = 0
End If
End Sub
seekingyou 2003-07-30
  • 打赏
  • 举报
回复
up
raulredondo 2003-07-30
  • 打赏
  • 举报
回复
你的画图的代码写在哪里的?如果把画图的代码写在paint事件里面,就不会发生那样的问题
thankuu 2003-07-30
  • 打赏
  • 举报
回复
ArLi2003,我按照你的方法写成以下,还是不行,怎么办呢?

PictureBox1.CreateGraphics.DrawLine(New Pen(Color.Black, 1), oldpt, newpt)
Me.pictureBox1.CreateGraphics().Save
ArLi2003 2003-07-30
  • 打赏
  • 举报
回复
must:

this.pictureBox1.CreateGraphics().Save
LesterYu 2003-07-30
  • 打赏
  • 举报
回复
应该要手动添加刷新的代码。
相关推荐
发帖
C#

10.9w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2003-07-30 09:07
社区公告

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