Clear image on picturebox

后端 未结 13 1774
不思量自难忘°
不思量自难忘° 2020-12-05 13:13

How can I clear draw image on picturebox? The following doesn\'t help me:

pictbox.Image = null;
pictbox.Invalidate();

Please help.

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 13:26

    I've had a stubborn image too, that wouldn't go away by setting the Image and InitialImage to null. To remove the image from the pictureBox for good, I had to use the code below, by calling Application.DoEvents() repeatedly:

                Application.DoEvents();
                if (_pictureBox.Image != null)
                    _pictureBox.Image.Dispose();
                _pictureBox.Image = null;
                Application.DoEvents();
                if (_pictureBox.InitialImage != null)
                    _pictureBox.InitialImage.Dispose();
                _pictureBox.InitialImage = null;
                _pictureBox.Update();
                Application.DoEvents();
                _pictureBox.Refresh();
    

提交回复
热议问题