Dear friends/ sir
i have two(2) windows form in my project . in first form i have button .
i want to perform a action that when i click the button which in form1
so that my second form load_event should be occour.
when i tried it says (error)
load_event does not exist in the current context
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj Kumar ChoudharyPosted Mar 26, 2015, 9:12 AM
In your form1 you should use this code:
private void Button1_Click(object sender, EventArgs e)
{
Form2 fn = new Form2();
fn.call();
}
in form 2 you can use this code:
object Obj;
EventArgs Se;
public void call()
{
Form2_Load(Obj, Se);
}
private void Form2_Load(object sender, EventArgs e)
{
MessageBox.Show("Pankaj Kumar Choudhary");
}
When you click on the button of form1 then this event call the Call() method of form2
in form2 call() method will again call the form load event.
You can also use this method
1. declare the form_load method as public of from2 now you can directly call Form_load method from form1
public void Form2_Load(object sender, EventArgs e)
{
MessageBox.Show("Pankaj Kumar Choudhary");
}
in form1
object Obj;
EventArgs Se;
private void Button1_Click(object sender, EventArgs e)
{
Form2 fn = new Form2();
fn.Form2_Load(Obj,Se);
}
I hope it will help you
Jiyalal GuptaPosted Mar 26, 2015, 10:16 AM
Jiyalal GuptaPosted Mar 26, 2015, 10:15 AM