Multiple Forms

T

Thom Little

I have two forms (Help and About).

How can I prevent one of the forms from being displayed when the other form
is currently displayed?

They are rendered from menu selections using ...

private void mnuHelp_Click( object sender, System.EventArgs e )
{
Form frm = new frmHelp( );
frm.ShowDialog( this );
}

private void mnuAbout_Click( object sender, System.EventArgs e )
{
Form frm = new frmAbout( );
frm.ShowDialog( this );
}

What was the source of your information?
 
M

mdb

I have two forms (Help and About).

How can I prevent one of the forms from being displayed when the other
form is currently displayed?

They are rendered from menu selections using ...

private void mnuHelp_Click( object sender, System.EventArgs e )
{
Form frm = new frmHelp( );
frm.ShowDialog( this );
}

private void mnuAbout_Click( object sender, System.EventArgs e )
{
Form frm = new frmAbout( );
frm.ShowDialog( this );
}


You could disable each menu item before the ShowDialog calls... eg...

private void mnuHelp_Click( object sender, System.EventArgs e )
{
Form frm = new frmHelp( );
mnuAbout.Enabled = false;
frm.ShowDialog( this );
mnuAbout.Enabled = true;
}

and

private void mnuAbout_Click( object sender, System.EventArgs e )
{
Form frm = new frmAbout( );
mnuHelp.Enabled = false;
frm.ShowDialog( this );
mnuHelp.Enabled = true;
}

-mdb
 
T

Thom Little

Excellent suggestion. It was also allowing multiple copies of the forms to
be spawned. Using your approach I solved both problems with ...

private void mnuHelp_Click( Object sender, System.EventArgs e )
{
Form frm = new frmHelp( );
private_ShowDialog( frm );
}

private void mnuAbout_Click( Object sender, System.EventArgs e )
{
Form frm = new frmAbout( );
private_ShowDialog( frm );
}

private void private_ShowDialog( Form frm )
{
this.mnuContext[3].Enabled = false ;
this.mnuContext[4].Enabled = false ;
frm.ShowDialog( this );
this.mnuContext[3].Enabled = true ;
this.mnuContext[4].Enabled = true ;
}

Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top