Prevent Multiple Forms
-
Hello, i have this code and i would like to prevent multipe new forms from opening [quote] private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.Show(); } [/quote] Any Idea of how i can implement this? :confused: D.M -- modified at 11:01 Monday 16th January, 2006
-
Hello, i have this code and i would like to prevent multipe new forms from opening [quote] private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.Show(); } [/quote] Any Idea of how i can implement this? :confused: D.M -- modified at 11:01 Monday 16th January, 2006
Have a bool value and set it to true when the export object is created.
bool exportCreated = false;
private void View_Click(object sender, EventArgs e)
{
if (!(exportCreated))
{
Export export = new Export();
export.Show();
exportCreated = true;
}
}Until you set exportCreated to false a new export object will not be able to be created. Cheers Kev
-
Hello, i have this code and i would like to prevent multipe new forms from opening [quote] private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.Show(); } [/quote] Any Idea of how i can implement this? :confused: D.M -- modified at 11:01 Monday 16th January, 2006
You can show your form as modal dialog
private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.ShowDialog(this); }
DevIntelligence.com - My blog for .Net Developers -
You can show your form as modal dialog
private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.ShowDialog(this); }
DevIntelligence.com - My blog for .Net Developers -
Hello, i have this code and i would like to prevent multipe new forms from opening [quote] private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.Show(); } [/quote] Any Idea of how i can implement this? :confused: D.M -- modified at 11:01 Monday 16th January, 2006
hi! :) you can also try this... :) private Export m_frmExport = null; private void View_Click(object sender, EventArgs e) { if (m_frmExport == null || m_frmExport.IsDisposed) { m_frmExport = new Export(); m_frmExport.Show(); } else { //If the m_frmExport is not yet closed/disposed, this will set the focus on this form. m_frmExport.Activate(); } } hope that helps. :)
-
Hello, i have this code and i would like to prevent multipe new forms from opening [quote] private void View_Click(object sender, EventArgs e) { Export export = new Export(); export.Show(); } [/quote] Any Idea of how i can implement this? :confused: D.M -- modified at 11:01 Monday 16th January, 2006
is your export form should be modal? If not, you can make your export form as class member and construct it in your main form contstructor and at View_Click(..) you can write only exportForm.Show(); Hope this help Hesham