Initial MDI form in VisualC #

Source: Internet
Author: User

It is very easy to make the MDI form in VB. This is not easy in C #, but it is very convenient.

First, add a form in C #, name it mdimain, and set ismdicontainer to true, so that the MDI main form is created. Then add a new form named mdichild. Run nowProgramOnly the mdimain form is running. Because we didn't write anythingCodeOf course, the second form cannot appear. Add this code now.

Add a menu on the mdimain form, and then write the sub menu at will. Double-click the sub-menu to display its click event. Write the following code in this event:

Mdichild frmmdichild = new mdichild ();
Frmmdichild.Mdiparent = this;
Frmmdichild. Show ();

In this way, the mdichild form is displayed when you click the menu item. However, this will cause a problem, that is, if I press the menu item twice, two mdichild forms will appear. Haha, this is because the form in C # Is a class, create an mdichild instance with the code you just created. Therefore, when you press the menu item several times, several forms will appear. One of the control methods is to write a variable to store whether the form is opened. If the form is opened, the execution will not continue. This small code is still very simple.

To close the mdichild form through a program, you only need to add a button in the mdichild and write close () in the Click Event of the button.

Related Article

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.