private void searchByWordToolStripMenuItem1_Click(object sender, EventArgs e)
{
Form2_Search_Word SearchWord = new Form2_Search_Word();
SearchWord.Show();
SearchWord.MdiParent = this;
}
But the problem is is when i click the menu strip is display a form as i click it again it shows another, another another. I want to restrict it if it already open and want to focus it. pleaes guide me i am the beginner
But the problem is is when i click the menu strip is display a form as i click it again it shows another, another another. I want to restrict it if it already open and want to focus it. pleaes guide me i am the beginner
Sudhakar ChaudharyPosted Jan 26, 2013, 2:57 AM
FormCollection fc = Application.OpenForms;
for (int i = 0; i < fc.Count; i++)
{
if (fc[i].Name == "Form2")
{
flag = true;
}
}
if (flag == false)
{
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
}
else
{
var result = MessageBox.Show("Form 2 Is Already Running. Want to Focus On It.", "Already Running.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
for (int i = 0; i < fc.Count; i++)
{
if (fc[i].Name == "Form2")
{
fc[i].Focus();
}
}
}
}
Faizan KhanPosted Jan 26, 2013, 9:26 AM