Home > Net >  Winform PictureBox repeated load images, figure is not refreshed
Winform PictureBox repeated load images, figure is not refreshed

Time:02-04

Is doing a project, winform interact with another platform, the platform will every captcha images saved to a Shared directory, the picture name is the same, "ABC. JPG", for example,
Winform after receiving the message, I do will pop up a input window, show the picture, lets the user input the verification code on the picture,
 
AutoIt. FrmCheckCode form2=new AutoIt. FrmCheckCode ();
Form2. GetPicture (" ABC. JPG ");
Form2. ShowDialog ();
MsgBox (form2. TxtCheckCode. Text + "!" , 1);
Form2. The Dispose ();

GetPicture code:
 
Public void GetPicture (string FileName)
{
PictureBox1. Image=Image. FromFile (FileName);
This. Width=pictureBox1. Image. Width + 16;
This. Height=pictureBox1. Image. Height + 75;
}

Messages are received for the first time, the pop-up window, can normal display images, but the second time, third time window pops up, display the image is still the first, but in fact the JPG this picture has changed, and research for a long time, I don't know what circumstance?

CodePudding user response:

PictureBox1. Refresh () and have a look

CodePudding user response:

reference 1st floor stherix response:
pictureBox1. Refresh () to see

No, strange.

CodePudding user response:

 
.=new Bitmap (Image. FromFile file. The FileName ());

CodePudding user response:

 
PictureBox1. ImageLocation=FileName;

CodePudding user response:

This Invoke ((MethodInvoker) delegate {pictureBox1. Image=Image. FromFile (FileName); });
You can try this method

CodePudding user response:

You first play a blank look at the effect of the picture, I wonder if you read the file, the file is not changed yet

CodePudding user response:

In addition, there are many ways of interaction across processes, don't use the file transfer
  •  Tags:  
  • C#
  • Related