One way would be to add a boolean static member variable to the form. Before creating the form, you could check the state of that variable. When the form is created, and later disposed, you could alter the state of that variable. While I haven't tested the following code, this should give you the idea...
Code:
public class MyOneForm : Form
{
private static bool s_isCreated = false;
public static bool IsCreated { return s_isCreated; }
public MyOneForm()
{
s_isCreated = true;
}
public void Dispose()
{
s_isCreated = false;
}
}
public class SomeOtherClass
{
public void DoSomeTask()
{
if (MyOneForm.IsCreated)
{
// Form has been created already.
}
else
{
MyOneForm frm = new MyOneForm();
frm.ShowDialog(this);
frm.Dispose();
}
}
}
Cheers.
- Roger Nedel