Dispose of a pictureBox image without losing the pictureBox

前端 未结 2 524
栀梦
栀梦 2021-01-23 02:01

I am writing a program that will play a slideshow (among other things). The slideshow is controlled by a backgroundWorker, and is set to a while(true) loop so it will constantly

2条回答
  •  感情败类
    2021-01-23 02:14

    What if you store the image to variable of that type and then set your picturebox image and then dispose the older one like

           Image oldImage = horPicBox.Image;
           horPicBox.Image = Image.FromFile(imagePaths[index]);
           oldImage.Dispose();
    

提交回复
热议问题