当前位置:网站首页>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 :

边栏推荐
- 2022 Jiangxi Provincial Safety Officer B certificate reexamination examination and Jiangxi Provincial Safety Officer B certificate simulation examination question bank
- Daily topic: movement of haystack
- leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]
- 如今少年已归来,人间烟火气最抚凡人心 复工了~
- 信息熵的基础
- Arduino DY-SV17F自动语音播报
- MySQL
- [flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
- 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
- 按键精灵打怪学习-自动回城路线的判断
猜你喜欢

【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
![leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]](/img/2c/8ec3926243fac8db9ed45d8053f3af.png)
leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]

Find a benchmark comrade in arms | a million level real-time data platform, which can be used for free for life

基本远程连接工具Xshell

Dotconnect for PostgreSQL data provider
![[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge](/img/ed/23331d939c9338760e426d368bfd5f.png)
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge

MySQL basics 03 introduction to MySQL types

Basic concept and implementation of overcoming hash

leetcode:871. 最低加油次数【以前pat做过 + 最大堆 +贪心】

Using tensorboard to visualize the model, data and training process
随机推荐
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Key wizard play strange learning - multithreaded background coordinate recognition
攻克哈希的基本概念与实现
【FPGA教程案例5】基于vivado核的ROM设计与实现
测试右移:线上质量监控 ELK 实战
Meituan dynamic thread pool practice ideas, open source
1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
Draw love with go+ to express love to her beloved
Druid database connection pool
每日一题之干草堆的移动
Daily topic: movement of haystack
Thinkphp+redis realizes simple lottery
leetcode:701. Insertion in binary search tree [BST insertion]
Strongly connected components of digraph
Esp32 simple speed message test of ros2 (limit frequency)
Kivy教程大全之如何在 Kivy 中创建下拉列表
【系统分析师之路】第五章 复盘软件工程(开发模型开发方法)
[FPGA tutorial case 5] ROM design and Implementation Based on vivado core
机器学习术语