I have a Menustrip With 1 Menu Item Say Add Record.
When i click on Add Record Menu Item assume Form1 is opened.
My Problem is When i click on Add Record for 5 Times. it is opening Form1 5 Times.
How to open Form1 Once only even though i clicked for N Times.
Its the MDI form
Thanks in Advance..
Loading

VulpesRank #55 · 29.2K reputationPosted Jun 13, 2011, 3:27 AM EDT
Veeramanikandan Dhanabalan20 reputationPosted Jun 13, 2011, 4:05 AM EDT
No.. not working....
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 13, 2011, 4:12 AM EDT
bool IsOpen = false;
foreach (Form f in Application.OpenForms)
{
if (f.Text == "Form2")
{
IsOpen = true;
f.Focus();
break;
}
}
if (IsOpen == false)
{
Form2 f2 = new Form2();
f2.Show();
}
Check this article http://www.c-sharpcorner.com/UploadFile/kirtan007/819/
Sam HobbsRank #107 · 20.5K reputationPosted Jun 13, 2011, 4:41 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 13, 2011, 4:49 AM EDT
If it's an MDI child, then it's not included in the Application.OpenForms collection and you'll have to do something like this instead:
Sam HobbsRank #107 · 20.5K reputationPosted Jun 13, 2011, 1:25 PM EDT