当前位置:网站首页>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 :
边栏推荐
- leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]
- Matlab Doppler effect produces vibration signal and processing
- Machine learning terminology
- 18_ The wechat video number of wechat applet scrolls and automatically plays the video effect to achieve 2.0
- [FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
- On Fibonacci sequence
- 按键精灵打怪学习-自动寻路回打怪点
- How is the mask effect achieved in the LPL ban/pick selection stage?
- Androd gradle's substitution of its use module dependency
- [my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
猜你喜欢
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
Asynchronous, email and scheduled tasks
wirehark数据分析与取证A.pacapng
Matlab Doppler effect produces vibration signal and processing
Niu Ke swipes questions and clocks in
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
Basic remote connection tool xshell
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge
Telephone network problems
Arduino dy-sv17f automatic voice broadcast
随机推荐
[system analyst's road] Chapter V double disk software engineering (development model development method)
【FPGA教程案例5】基于vivado核的ROM设计与实现
Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man
Matlab Doppler effect produces vibration signal and processing
Telephone network problems
Arduino dy-sv17f automatic voice broadcast
【FPGA教程案例6】基于vivado核的双口RAM设计与实现
Button wizard play strange learning - automatic return to the city route judgment
Using tensorboard to visualize the model, data and training process
Why can't the start method be called repeatedly? But the run method can?
MySQL
[self management] time, energy and habit management
Esp32 simple speed message test of ros2 (limit frequency)
Specified interval inversion in the linked list
How is the mask effect achieved in the LPL ban/pick selection stage?
Appuyez sur l'apprentissage de l'esprit de frappe - reconnaissance des coordonnées de fond multithreadées
不登陆或者登录解决oracle数据库账号被锁定。
Trois tâches principales: asynchrone, courrier et timing
一位苦逼程序员的找工作经历
如今少年已归来,人间烟火气最抚凡人心 复工了~