menus and mdi

  • Thread starter Thread starter blah
  • Start date Start date
B

blah

if i have an mdi parent with a menu option of View->source and this menu
item creates a new child window how do i make a checkmark appear when the
child form is loaded and have the checkmark dissapear when the childwindow
is closed? and how do i stop a child window from being created more than
once (if the user selects it more than once)?

thanks,
Rob
 
Hi Blah,

I think you can create 2 public method in MainForm which functions are make
and cancel the checkmark of menuitem.
Then, in child form's load and closing event, you can invoke these 2 method.
Sample code snippet:

///////////////////////Main form//////////////////////////////////
//View->Source menuitem click event
private void showsource_Click(object sender, System.EventArgs e)
{
if(showsource.Checked==false)
{
Form2 f2=new Form2();
f2.MdiParent=this;
f2.Show();
}
}

public void open_childwnd()
{
this.showsource.Checked=true;
}

public void close_childwnd()
{
this.showsource.Checked=false;
}

//////////////////////child form/////////////////////////
private void Form2_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
Form1 f=(Form1)this.MdiParent;
f.close_childwnd();
}

private void Form2_Load(object sender, System.EventArgs e)
{
Form1 f=(Form1)this.MdiParent;
f.open_childwnd();
}

It works well on my machine, if you still have anything unclear, please
feel free to tell me.
Have a nice day.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "blah" <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Subject: menus and mdi
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <WRAmb.84872$Ms2.80440@fed1read03>
| Date: Sat, 25 Oct 2003 13:15:43 -0700
| NNTP-Posting-Host: 68.98.3.94
| X-Complaints-To: (e-mail address removed)
| X-Trace: fed1read03 1067112950 68.98.3.94 (Sat, 25 Oct 2003 16:15:50 EDT)
| NNTP-Posting-Date: Sat, 25 Oct 2003 16:15:50 EDT
| Organization: Cox Communications
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!npeer.de.kpn-eurorings.net!cox.net!news-xfer.cox.net!p01!fed1read03.POS
TED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194053
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| if i have an mdi parent with a menu option of View->source and this menu
| item creates a new child window how do i make a checkmark appear when the
| child form is loaded and have the checkmark dissapear when the childwindow
| is closed? and how do i stop a child window from being created more than
| once (if the user selects it more than once)?
|
| thanks,
| Rob
|
|
|
 
thanks, that's what i was looking for and it works like a charm.

thanks,
Rob

"Jeffrey Tan[MSFT]" said:
Hi Blah,

I think you can create 2 public method in MainForm which functions are make
and cancel the checkmark of menuitem.
Then, in child form's load and closing event, you can invoke these 2 method.
Sample code snippet:

///////////////////////Main form//////////////////////////////////
//View->Source menuitem click event
private void showsource_Click(object sender, System.EventArgs e)
{
if(showsource.Checked==false)
{
Form2 f2=new Form2();
f2.MdiParent=this;
f2.Show();
}
}

public void open_childwnd()
{
this.showsource.Checked=true;
}

public void close_childwnd()
{
this.showsource.Checked=false;
}

//////////////////////child form/////////////////////////
private void Form2_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
Form1 f=(Form1)this.MdiParent;
f.close_childwnd();
}

private void Form2_Load(object sender, System.EventArgs e)
{
Form1 f=(Form1)this.MdiParent;
f.open_childwnd();
}

It works well on my machine, if you still have anything unclear, please
feel free to tell me.
Have a nice day.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "blah" <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Subject: menus and mdi
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <WRAmb.84872$Ms2.80440@fed1read03>
| Date: Sat, 25 Oct 2003 13:15:43 -0700
| NNTP-Posting-Host: 68.98.3.94
| X-Complaints-To: (e-mail address removed)
| X-Trace: fed1read03 1067112950 68.98.3.94 (Sat, 25 Oct 2003 16:15:50 EDT)
| NNTP-Posting-Date: Sat, 25 Oct 2003 16:15:50 EDT
| Organization: Cox Communications
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!cox.net!news-xfer.cox.net!p01!fed1read03.POS
TED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194053
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| if i have an mdi parent with a menu option of View->source and this menu
| item creates a new child window how do i make a checkmark appear when the
| child form is loaded and have the checkmark dissapear when the childwindow
| is closed? and how do i stop a child window from being created more than
| once (if the user selects it more than once)?
|
| thanks,
| Rob
|
|
|
 
Back
Top