In windows form (c#), i am showing a form when user click on button, it is working fine form is visible to user, but if user click again on the same button the same form is opening again two forms are displaying. Is there any way to prevent this, please give me any reference for this thank you. This is my code….
private void button1_Click(object sender, EventArgs e)
{
Form2 obj = new Form2();
obj.Show();
}
You are most likely doing something like this:
So you are showing a new instance of the form every time it is clicked. You want to do something like this:
Here you have just one instance of the form you wish to show, and just Show() it.