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

边栏推荐
- Key wizard hit strange learning - automatic path finding back to hit strange points
- R language uses coin package to apply permutation tests to independence problems (permutation tests, whether response variables are independent of groups, are two numerical variables independent, and
- R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
- Create your first Kivy program Hello word (tutorial includes source code)
- Meituan dynamic thread pool practice ideas, open source
- 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
- Telephone network problems
- 按键精灵打怪学习-自动寻路回打怪点
- Kivy教程大全之 创建您的第一个kivy程序 hello word(教程含源码)
- How is the mask effect achieved in the LPL ban/pick selection stage?
猜你喜欢

寻找标杆战友 | 百万级实时数据平台,终身免费使用

Esp32 simple speed message test of ros2 (limit frequency)

异步、邮件、定时三大任务
![[Androd] Gradle 使用技巧之模块依赖替换](/img/5f/968db696932f155a8c4a45f67135ac.png)
[Androd] Gradle 使用技巧之模块依赖替换

Arduino dy-sv17f automatic voice broadcast

MySQL foundation 05 DML language
![[C language] detailed explanation of pointer and array written test questions](/img/24/c2c372b5c435cbd6eb83ac34b68034.png)
[C language] detailed explanation of pointer and array written test questions
![[principles of multithreading and high concurrency: 2. Solutions to cache consistency]](/img/ce/5c41550ed649ee7cada17b0160f739.jpg)
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
![[Arduino experiment 17 L298N motor drive module]](/img/e2/4511eaa942e4a64c8ca2ee70162785.jpg)
[Arduino experiment 17 L298N motor drive module]

Detailed explanation of Q-learning examples of reinforcement learning
随机推荐
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
kivy教程之在 Kivy App 中使用 matplotlib 的示例
JS inheritance and prototype chain
Is there a handling charge for spot gold investment
数学知识:Nim游戏—博弈论
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
wirehark数据分析与取证A.pacapng
Kivy tutorial - example of using Matplotlib in Kivy app
18_ The wechat video number of wechat applet scrolls and automatically plays the video effect to achieve 2.0
ThinkPHP+Redis实现简单抽奖
Dotconnect for PostgreSQL data provider
Find a benchmark comrade in arms | a million level real-time data platform, which can be used for free for life
Embrace the safety concept of platform delivery
【FH-GFSK】FH-GFSK信号分析与盲解调研究
异步、郵件、定時三大任務
Is there anything in common between spot gold and spot silver
Assets, vulnerabilities, threats and events of the four elements of safe operation
The meaning of wildcard, patsubst and notdir in makefile
leetcode 2097 — 合法重新排列数对
Leetcode 2097 - Legal rearrangement of pairs