Is there a way to prevent the opening of a certain form within an MDI container if that said form is already opened?
AFAIK there is no standard way. You'll have to implement it yourself. I'd do it this way:
class TheForm: Form
{
private static TheForm Instance;
private TheForm() // Constructor is private
{
}
public static Show(Form mdiParent)
{
if ( Instance == null )
{
// Create new form, assign it to Instance
}
else
Instance.Activate(); // Not sure about this line, find the appropriate equivalent yourself.
}
protected override OnFormClose(EventArgs e)
{
Instance = null;
base.OnFormClose(e);
}
}
If thread safety is of concern, add the appropriate locks.