Windows窗体应用程序中pictureBox的问题
代码很简单,picLoad是加载一张图,Draw是画个框。
如下,按钮1是加载,按钮2是画框,按钮3是先加载再画框。
先按button1 ,再按button2,正常运行。
如果只按Button3,却不会画出框来,只加载了图片。
请问怎么办???我不想分步啊。。。
(经过研究,按BUTTON3的时候,系统好像在加载图片之前先画了框了。。。这可如何是好)
(picLoad里现在用的是picBox.Image=xxx的方法。一样没用。。。和注释掉的load方法一样的情况)
void PicLoad() { Image i = Image.FromFile(@"D:\temp.bmp"); this.pictureBox1.Image = i; //this.pictureBox1.Load(@"D:\temp.bmp"); } void Draw() { Graphics g = this.pictureBox1.CreateGraphics(); g.DrawRectangle(new Pen(Color.Gold), 0, 0, 100, 100); } private void button1_Click(object sender, EventArgs e) { PicLoad(); } private void button2_Click(object sender, EventArgs e) { Draw(); } private void button3_Click(object sender, EventArgs e) { PicLoad(); Draw(); }