Image not being displayed
Hello everyone,
The problem with the code below is that pictureBox2 is not displaying the image.
public static void updateImage()
{
Image img;
Form1 myClass = new Form1();
img = myClass.pictureBox1.Image;
myClass.pictureBox2.Image = img;
}
My guess is that it is because I have to create a new instance of the Form1 class. Any suggestions?
Many thanks in advance,
bassguru
Re: Image not being displayed
A more efficient version of that code is:
public static void updateImage()
{
Form1 myClass = new Form1();
myClass.pictureBox2.Image = myClass.pictureBox1.Image;
}
Same problem still exists I'm afraid.
Bassguru
Re: Image not being displayed
that's not enough code to tell you what to do... I'll be guessing:
public static void updateImage()
{
this.pictureBox2.Image = this.pictureBox1.Image;
}
Re: Image not being displayed
Thanks for the reply memeloo,
However, I get the following error message:
"Keyword 'this' is not valid in a static property, static method, or static field initializer"
Essentially, I am attempting to copy one image and display it in a second pictureBox. What method would be most appropriate for this, as I do not believe it can be done in a 'public static void' method.
I am calling this method by doing the following:
protected static void Connect()
{
Thread newThread = new Thread(new ThreadStart(updateImage));
newThread.Start();}
Many thanks,
bassguru
Re: Image not being displayed
this is still not enough and if you don't want us to guess post the whole code.
Re: Image not being displayed
Is the new Form is getting created in the original parent thread or in the new thread you are calling ?