Form Common Properties:
BackgroundImage: Setting a background picture
BackgroundImageLayout: For component background Image layout
BackColor: Gets or sets the background color of the control
Use of form common events:
Private voidForm1_Load (Objectsender, EventArgs e)//form Load event {//result gets the return value of the dialog boxDialogResult result = MessageBox.Show ("whether to open the form","Tips", MessageBoxButtons.OK, messageboxicon.question);//displays a message box with text, Caption, button, icon (left to right) if(Result = =DialogResult.OK) This. Show (); }//form Activation EventsPrivate voidForm1_activated (Objectsender, EventArgs e) { //MessageBox.Show ("form activated! "); //This event is triggered when the form is activated because the form is always active and can be used to rebind data for controls in the database}//closing Form EventsPrivate voidForm1_formclosing (Objectsender, FormClosingEventArgs e) {DialogResult result= MessageBox.Show ("whether to close the form","Tips", Messageboxbuttons.okcancel, messageboxicon.warning); if(Result = =DialogResult.OK) {e.cancel=false;//indicates that the event should not be canceled and continues to close } Else if(Result = =dialogresult.cancel) {e.cancel=true;//indicate cancel event, stop shutdown}}//form calls between formsPrivate voidButton1_Click (Objectsender, EventArgs e) {Form2 F2=NewForm2 (); F2. ShowDialog ();//displays the form as a dialog box, which is a modal form, at which point the Form1 (other form) is not visible, and if it is the Show method, two forms can see//F2. Hide ();//hides the form, and the resources it occupies are not released}
MDI multi-Document interface:
1. Set the parent form's IsMdiContainer to True
2. Add Menuscrip Menu Component
3. Add an Event Display subform, you can display multiple subforms, layout the subform with LayoutMDI (MDILayout x) method, mdilayout as enum type
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacewindowsformsapplication6{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }//Display the subformPrivate voidShow Toolstripmenuitem_click (Objectsender, EventArgs e) {Form2 F2=NewForm2 (); F2. MdiParent= This; F2. Show (); FORM3 f3=NewForm3 (); F3. MdiParent= This; F3. Show (); FORM4 f4=NewFORM4 (); F4. MdiParent= This; F4. Show (); } Private voidArrange Toolstripmenuitem_click horizontally (Objectsender, EventArgs e) {LayoutMDI (mdilayout.tilehorizontal);//horizontal arrangement of subforms } Private voidVertical arrangement Toolstripmenuitem_click (Objectsender, EventArgs e) {LayoutMDI (mdilayout.tilevertical);//Vertical arrangement of subforms
Private void cascade permutation Toolstripmenuitem_click (object sender, EventArgs e)
LayoutMDI (Mdilayout.cascade); //Cascade sub-forms
}