I have a winform application, in which from parent form I open a child form. This child form can be opened from multiple parent forms. But when opened from a specific parent form, I want a message box to display when the child form gets minimized. Basically I want to check the name of the parent form which is an .exe and display the message box. Both child and parent forms are .exe.
Asked
Active
Viewed 458 times
-2
-
1And the question is? – Sinatr May 18 '16 at 10:18
-
I am not able to get the parent .exe name. – Nikhil Kumar May 18 '16 at 10:23
-
When opening form you can pass current parent form name as parameter. See e.g. [this](http://stackoverflow.com/q/17836398/1997232). – Sinatr May 18 '16 at 10:33
1 Answers
0
if (Application.OpenForms.Cast<Form>().Any(form => form.Name == "<YOUR_CHILD_FORM_NAME>"))
{
Form tempForm = Application.OpenForms.Cast<Form>().FirstOrDefault(form => form.Name == "<YOUR_CHILD_FORM_NAME>");
if (tempForm.WindowState == FormWindowState.Minimized)
{
// FORM IS OPEN AND ALSO IN MINIMIZE MODE
}
else
{
// FORM IS OPEN BUT NOT IN MINIMIZE MODE
}
}
else
{
// FORM IS NOT OPEN
}
NOTE
While opening of your child form you must have to set name of your child window like....
ChildForm cForm = new ChildForm();
cForm.Name = "<YOUR_CHILD_FORM_NAME>";
cForm.Show();

Darshan Faldu
- 1,471
- 2
- 15
- 32