I. Design of MDI Form
1.MDI Introduction
MDI (Multiple document Interface) is the so-called multi-document interface , which corresponds to a single document interface (SDI), which is Microsoft Corporation from Microsoft Windows 2.0 when an Excel spreadsheet program is introduced, an Excel spreadsheet user sometimes needs to manipulate multiple tables at the same time, and MDI is a great convenience for such operations, resulting in an MDI program
2.:
As shown, multiple forms are nested, one of which is the parent form, and its bar is a subform.
Arrange the following forms horizontally:
Arrange the following form vertically:
Close all subforms:
3. Implementation process
1), create a new window form program
2) Create a new 4 form
3), back-end implementation code
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceMDI Design { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidShow Subform Toolstripmenuitem_click (Objectsender, EventArgs e) { Form f2 = new Form2 (); F2. MdiParent = this; // specify its MDI parent form F2. Show (); Form f3=NewForm3 (); F3. MdiParent= This; F3. Show (); Form f4=NewFORM4 (); F4. Show (); F4. MdiParent= This; } Private voidHorizontal Arrangement Toolstripmenuitem_click (Objectsender, EventArgs e) {LayoutMDI (mdilayout.tilehorizontal); } Private voidVertically arranged Toolstripmenuitem_click (Objectsender, EventArgs e) {LayoutMDI (mdilayout.tilevertical); } Private voidClose all Forms Toolstripmenuitem_click (Objectsender, EventArgs e) { foreach(Form Finch This. Mdichildren) {f.close (); } } }}
All source code implementation: Https://github.com/amosli/CSharp/tree/mdi
The menu options are MenuStrip controls, which are also very simple and easy to use, as shown below:
Second, MenuStrip control
Create a new MenuStrip control, and then write the name, and double-click to define its events, such as the horizontal and vertical arrangement above.
Three, PictureBox controls and timer controls
1. Look First:
2. Implementation process
New controls for PictureBox and timer
In order to achieve the relative size of the PictureBox control, it is important to note that changing the anchor layout is all checked!
Format the picture display:
Timer control interval Time setting:
Events performed at intervals:
3. Background implementation Code
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.IO;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacePictureBox Control Learning { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } /// <summary> ///Timer Change Time/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidTimer1_Tick (Objectsender, EventArgs e) {Lbtime.text= DateTime.Now.ToString ("YYYY-MM-DD HH:mm:ss"); } Public StaticString Imgdirpath =@"C:\work\img"; String[] Imgpaths= Directory.GetFiles (Imgdirpath,"*.jpg"); Public Static intImgnum =0; /// <summary> ///Implementing a previous page button/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidBtnprevious_click (Objectsender, EventArgs e) {Imgnum--; if(Imgnum <0) {Imgnum= imgpaths.length-1; } pbogirls.imagelocation=Imgpaths[imgnum]; } /// <summary> ///implementing the next page button/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> Private voidBtnnext_click (Objectsender, EventArgs e) {Imgnum++; if(Imgnum >=imgpaths.length) {imgnum=0; } pbogirls.imagelocation=Imgpaths[imgnum]; } /// <summary> ///Random Browsing/// </summary>Random rnd =NewRandom (); Private voidButton1_Click (Objectsender, EventArgs e) {pbogirls.imagelocation=Imgpaths[rnd. Next (Imgpaths.length)]; } }}
All Source:Https://github.com/amosli/CSharp/tree/picturebox