I need a little help with detecting if another form is running in my application
To keep it simple if a user opens Form2 from Form1 ideally in my form close event from Form1 I would like to check if Form2 is open and if it is perform a task, I have kind of got it working using try, catch blocks but it's a bit crude!
Can someone give an example please of how best to execute this within the below form closing event:
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
}
mike DelvottiPosted Jul 15, 2014, 5:52 AM
Thanks for that advice,
I have found a solution that appears to work great and hopefully better than my try, catch blocks
if (Application.OpenForms.OfType().Count() > 0)
{
MessageBox.Show("Form2 open");
}
Guest UserPosted Jul 15, 2014, 5:33 AM