.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

call a function from Form to another form using C#.net

Posted By: Narayanan     Posted Date: April 18, 2012    Points:5   Category :Windows Application
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
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.Show();
}


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


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

}
Form3
Declaration
Form1 frm = new Form1;

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...

Responses
Author: Murali             
Posted Date: June 04, 2012     Points: 20   

Make the Message method in the form1 as static and call it from Form3 as: Form1.Message();



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend