当前位置:网站首页>C application interface development foundation - form control (2) - MDI form
C application interface development foundation - form control (2) - MDI form
2022-07-03 01:27:00 【DXB2021】
MDI forms
Single document interface (SDI)
Multi document interface (MDI)
MDI The concept of form
MDI forms (Multiple-Document Interface, Multi document interface ) Used to display multiple documents at the same time .
Used in projects MDI On the window , Usually a MDI Window form as parent form , A parent form can contain multiple child forms in its workspace .
Set up MDI forms
1、MDI Container form
Set a form as a window form , There are two ways :
1、 On the window “ attribute ” The palette , take IsMidContainer Property is set to True that will do .

False:

True:

2、 On the window Load Add the following statement to the event

The code is as follows :
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.IsMdiContainer = true;
}
}
}
2、 Set up MDI Subform
MDI A subform is a normal form . You only need to convert the MdiParent Property to a MDI Parent form , It is the child form of the parent form , The syntax is as follows :
Form instance name .MdiParent= Parent form object ;
Set up MDI Containers :

After modification :

from Form5 In the attribute , adopt Name Property to change to “MainForm”

After modification :

Text Property represents the form title , It is amended as follows “MDI forms ”

After modification :

New subform (Form1.cs、Form2.cs、Form3.cs、Form4.cs):

Code content :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Form5
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.Show();
form1.MdiParent = this;
Form2 form2 = new Form2();
form2.Show();
form2.MdiParent = this;
Form3 form3 = new Form3();
form3.Show();
form3.MdiParent = this;
Form4 form4 = new Form4();
form4.Show();
form4.MdiParent = this;
}
}
}After completion :

The operation results are as follows :

array MDI forms
The syntax is as follows :
public void LayoutMdi(MdiLayout value)
value yes MdiLayout One of the enumeration values of , Used to define MDI Layout of subform .
| Members of the enumeration | explain |
| Cascade | Cascade arrangement MDI Subform |
| TileHorizontal | Tile horizontally MDI Subform |
| TileVertical | Tile vertically MDI Subform |
Create a new one Windows Forms application , stay Name Property to name the form unique identifier MainForm, And in Text Properties of the , Name the title of the main form “MDI forms ”.
Select from the menu bar “ View ” command , Re selection “ hold-all ” command , The toolbox will pop up .

Select... In the toolbox MenuStrip Control , A row of menu bars will appear in the form , And then enter “ New form ”、“ Cascade arrangement ”、“ Tile horizontally ”、“ Tile vertically ”、“ close ”.



next , then IsMdiContainer Property is set to True.
Create a subform , And named it “ChildForm”, Next, you can double-click the menu item , Add events .

The code is as follows :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Form5
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.Show();
form1.MdiParent = this;
Form2 form2 = new Form2();
form2.Show();
form2.MdiParent = this;
Form3 form3 = new Form3();
form3.Show();
form3.MdiParent = this;
Form4 form4 = new Form4();
form4.Show();
form4.MdiParent = this;
}
private void New form ToolStripMenuItem_Click(object sender, EventArgs e)
{
ChildForm mychildForm=new ChildForm();
mychildForm.Show();
mychildForm.MdiParent = this;
}
private void Cascade arrangement ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);
}
private void Tile horizontally ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);
}
private void Tile vertically ToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);
}
private void close ToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
}
}
The operation results are as follows :

Click new form :


Cascade arrangement :

Tile horizontally :

Tile vertically :

边栏推荐
- Look at how clothing enterprises take advantage of the epidemic
- 按键精灵打怪学习-前台和内网发送后台验证码
- Basic remote connection tool xshell
- Kivy tutorial - example of using Matplotlib in Kivy app
- 力扣 204. 计数质数
- 18_ The wechat video number of wechat applet scrolls and automatically plays the video effect to achieve 2.0
- 机器学习术语
- 一比特苦逼程序員的找工作經曆
- Excel removes the data after the decimal point and rounds the number
- kivy教程之在 Kivy App 中使用 matplotlib 的示例
猜你喜欢

Trois tâches principales: asynchrone, courrier et timing

Database SQL language 02 connection query

MySQL foundation 04 MySQL architecture

Database SQL language 01 where condition

Embrace the safety concept of platform delivery

JDBC courses

Excel calculates the difference between time and date and converts it into minutes

给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】

Daily topic: movement of haystack

Using tensorboard to visualize the model, data and training process
随机推荐
Correctly distinguish the similarities and differences among API, rest API, restful API and web service
给你一个可能存在 重复 元素值的数组 numbers ,它原来是一个升序排列的数组,并按上述情形进行了一次旋转。请返回旋转数组的最小元素。【剑指Offer】
Basis of information entropy
[day 29] given an integer, please find its factor number
Merge K sorted linked lists
How is the mask effect achieved in the LPL ban/pick selection stage?
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
R language ggplot2 visual faceting, visual facet_wrap bar plot, using strip Text function customize the size of the strip of each facet title in the facet graph (cutimi
What are the trading forms of spot gold and what are the profitable advantages?
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
基本远程连接工具Xshell
MySQL foundation 04 MySQL architecture
LDC Build Shared Library
d. LDC build shared library
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在
How is the mask effect achieved in the LPL ban/pick selection stage?
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
Give you an array numbers that may have duplicate element values. It was originally an array arranged in ascending order, and it was rotated once according to the above situation. Please return the sm
wirehark数据分析与取证A.pacapng