In my application I want to be able to open a new instance of a form as a child multiple times while they have a unique identifier.
At the moment I do like this:
private int _consoleWindowCount = 0;
private void tsBtNewConsole_Click(object sender, EventArgs e)
{
_consoleWindowCount++;
var consoleForm = new ConsoleForm(_consoleWindowCount) { MdiParent = this };
consoleForm.FormClosing += delegate { _consoleWindowCount--; };
consoleForm.Show();
//This will open a new ConsoleForm with Text: Console #_consoleWindowCount
//Like:
// Console #1
// Console #2
}
I have 2 problems at the moment:
- How is it possible that from MDIForm (mainForm) I can programatically doe stuff like BringToFront or Close or ... by the Text property of child forms currently open in the main form
- I should not be a genius to find out this way of unique naming of the child forms is not working. If I open 5 child forms (of same form) they will be numbered like
Console #1
toConsole #5
. But if I close lets sayConsole #4
and if I open a new form (of same form!) it will be namedConsole #5
then I will have two forms with same name. if this can be fixed, it will be great for forms being distinguishable by user.
Looking forward to your tips in such a case!