I have a form "fm" that is a simple info window that opens every 10 mins (fm.Show();
).
How I can make that every 10 mins it will check if the form "fm" is open and if it is open it closes it and open it again!
Now the form fm is always created with form fm = new form();
so when I try to check if the form is open it will always be false and open a new window even if there is one form before!
I need to have a tool to give it a unique identity and then check if this form with unique identity is opened or not!
I do not want to just update the data on the form (fm), because I have a complicated info with buttons.
The form name is "UpdateWindow"
Solved using the following:
Form fc = Application.OpenForms["UpdateWindow"];
if (fc != null)
fc.Close();
fc.Show();
Try to wire below,
By wiring above event, it will tell you whenever the form is minimized, partially/totally hided by another form.
Suppose if we are calling a form from a menu click on MDI form, then we need to create the instance declaration of that form at top level like this:
Then we need to define the menu click event to call the Form1 as follows:
The CheckOpened defined to check the Form1 is already opened or not:
Hope this will solve the issues on creating multiple instance of a form also getting focus to the Form1 on menu click if it is already opened or minimized.
try this MDICHILD function
I'm not sure that I understand the statement. Hope this helps. If you want to operate with only one instance of this form you should prevent Form.Dispose call on user close. In order to do this, you can handle child form's Closing event.
And then you don't need to create new instances of
frm
. Just call Show method on the instance.You can check Form.Visible property to check if the form open at the moment.
Actually, I still don't understand why don't you just update the data on the form.
It will close the form1 you can open that form again if you want it using :