Some settings for MDI forms in C #

Source: Internet
Author: User

Once theMDI child form is enlarged, the subform icon crosses the menu bar and runs to the top.

Sets the Mainmenustrip property in the parent window to the menustrip! of the parent window

Two

1. Establish the MainForm (set attribute ismdicontainer=true) parent form as shown below.

2. Double-click the Form1 icon on the toolbar. Sets the display for the Form1 subform.

The Form1 Subform display code is as follows:

Private void Toolstripbutton1_click (objectsender, EventArgs e)

{

Form1 f1= new Form1 ();

F1. WindowState = formwindowstate.normal;

F1. MdiParent = this ;

F1. Show ();

}

3. Select the menu bar MenuStrip1 to set its ItemAdded event.

The ItemAdded event code for MENUSTRIP1 is as follows:

Private void menustrip1_itemadded (objectsender, toolstripitemeventargs e)

{

if (e.item.text.length = = 0 // Hide child form icon

|| E.item.text = = " minimize (&n)" // Hide Minimize button

|| E.item.text = = " restore (&r)" // Hide Restore button

|| E.item.text = = " off (&c)")// Hide most Close button

{

E.item.visible = false;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.