Since I don't have much reputation to post image, I am elaborating as a big question.
I have three windows forms in which the execution of events get increased each time the form is created.
1. Form1(MainForm)
Here I call the second form(SubForm) which contains a user control.
2. Form2(SubForm)
Here I call the second form(ChildForm) by clicking the user control.
3. Form3(ChildForm)
It contains an OK button.
Here is my problem.
Here is the code in first form(MainForm)
private void button1_Click(object sender, EventArgs e)
{
SubForm obj = new SubForm ();
obj.ShowDialog();
}
Here is the code in second form(SubForm) which contains user control
// Event generation
UserControl1.MouseUp += new EventHandler(this.Node_Click);
// Event that calls the ChildForm
private void Node_Click(object sender, EventArgs e)
{
ChildForm obj = new ChildForm();
obj.ShowDialog();
}
Here is the code in first form(MainForm)
private void btnOK_Click(object sender, EventArgs e)
{
this.Close();
}
Anyone knows why this is happening?
Hey I am not really sure what's happening but if you want the node_click to be applied only once just declare a bool var canEnter=true; and do this
private void Node_Click(object sender, EventArgs e) {
if(canEnter) {
ChildForm obj = new ChildForm();
obj.ShowDialog();
canEnter=false;
}
}
and make event for the child form (closed event) and place in it canEnter=true; if I got you right I guess that's what you need to do :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With