|
-
February 24th, 2010, 10:35 AM
#1
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
-
February 24th, 2010, 10:40 AM
#2
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
-
February 24th, 2010, 12:47 PM
#3
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;
}
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
February 24th, 2010, 12:55 PM
#4
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
-
February 24th, 2010, 01:04 PM
#5
Re: Image not being displayed
this is still not enough and if you don't want us to guess post the whole code.
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
February 25th, 2010, 07:10 AM
#6
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 ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|