C#Windows Forms (1)--xdd

1. Replace form icon

Methods: Click the form, change the icon property.

2. Adjust the default position when the form opens

Methods: Click the form, change StartPotion property.

3. Modify the form size

Methods: Click the form, change the Size property.

4. Set the form's background image

Methods: Click the form, BackgroundImage property changes.

5. Open the new form

 

First create a form and then 

 

Form2 frm2 = new Form2(); frm2.Show(); this.Hide();

 

 

 

 

6. Click the Form Click event

 

First, double-click the Click event of the Form Properties

MessageBox.Show ( " 've clicked Form " ); // pop-up boxes

 

 

 7. Load the form load event

For example: when you open the window, pop-up boxes asking if you view the form           

if (MessageBox.Show("是否查看窗体?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
            }

8. The window closing event FormClosing

Dr = MessageBox.Show DialogResult ( " Are you sure you want to close the window " , " tips " , MessageBoxButtons.YesNo, MessageBoxIcon.Warning); // create a dialog 
            IF (dr == DialogResult.Yes) 
            { 
                the e.Cancel = to false ; // if you click "yES", then close the window 
            }
             the else    // else 
            { 
                the e.Cancel = to true ; // the operation is not performed 
            }

 

Guess you like

Origin www.cnblogs.com/xdd1997/p/11241675.html