Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Project has a 3 Forms.that is Form1,Form2,Form3.One button is in the Each form.One Function is in the Form that is called Message(). I just call that function from Form3.
But It is not worked.

Form1
C#
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.Show();
}

Function
C#
public void message()
{
pictureBox1.ImageLocation = @"C:\Documents and Settings\User\My Documents\My Pictures\index.JPEG";
}



Form2
C#
private void button1_Click(object sender, EventArgs e)
{
this.Close();
Form3 frm = new Form3();
frm.Show();

}

Form3
Declaration
C#
Form1 frm = new Form1;


C#
private void button1_Click(object sender, EventArgs e)
{

frm.message();
this.Close();
}


But it is not worked.Please help me.why?I upload a picture in the Picture Box. how to solve this issue?Please do needful...
Posted
Updated 18-Apr-12 1:10am
v2

It depends what you are expecting to happen when you call the message method.
If you are expecting it to set the ImageLocation property of pictureBox1 on the new instance of Form1 (which you can't see) then it is doing exactly what you are expecting.

If you are expecting it to affect the pictureBox1 on the existing Form1 that created For2 and Form3, or to affect a PictureBox of For2 or Form3, then it won't, and you need to think carefully about what you are doing, and access the actual instance of the form that you expect to affect.

What are you trying to do? What do you expect it to do?
 
Share this answer
 
MAKE TO FORM3 OBJECT AND CALL THAT FUNCTION . . .
LIKE:

FORM1 FRM = NEW FORM1();
FRM.MESSAGE();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900