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 the program now and you will find that only the main form of MdiMain is running. Because we didn't write any code, the second form certainly won't 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, there will be 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.