Use of Windows Form

Source: Internet
Author: User

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



}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.