Initial Windows system

Source: Internet
Author: User

I. Properties of a form

1. Background color: BackColor
2. Background Image: BackgroundImage
3. Set the form title: Text
4. Form icon: Icon
5. Set the form to change size: Formboderstyle
6. Setting the form display location: startposition
7. Set the background image tiling method: BackgroundImageLayout
8. The Settings drop-down box cannot be changed: DropDownStyle
9. Set Password box display text: PasswordChar

Two. Form controls

1. Tags: lable prefix: LBL
2. Text box: TextBox prefix: TXT
3. Combo box: ComboBox prefix: CBO
4. Buttons: Button prefix: btn

Three. Registering events for a control


Click on the control, click Lightning, select the event you want to register double-click

If you want to delete the event code, you need to do so after the deletion. Remove the error code from the Designer.cs file

Four. Message Prompt box

MessageBox.Show ("hint message");
MessageBox.Show ("Prompt message", "hint title");
MessageBox.Show ("Hint info", "hint title", Messageboxbuttons.yesno (ok Cancel button));
MessageBox.Show ("Hint info", "hint title", Messageboxbuttons.yesno (ok Cancel button), messageboxicon.stop (hint image));

1. Receive the return value of the prompt box

Friendly hints, message boxes
DialogResult result=messagebox.show ("OK to cancel login?") "," Hehe! ", Messageboxbuttons.yesno,messageboxicon.error);
Determine the value of the message box click button
if (result = = Dialogresult.yes) {
Close the form
This. Close ();
}

Five. Get the value of the text box input

1. This. TextBox name. Text
2. Get text Box focus

this. text box name. Fouce ();
Six. Show the form and pass the value

1. Presentation form

Form name Instance name =new form name ();
The instance name. Show ();

Frmmain main=new frmmain ();
Main. Show ();

2. Form Passing value
Pass the value of one form into another form

Solution One: Pass values in when you create an instance of the form
Frmmain main=new frmmain (incoming value);
Public frmmain (formal parameters)
{

InitializeComponent ();
This. text= formal parameters;
}

Solution Two: Register a load () event that will automatically call load () before the form show ()

Frmmain main = new Frmmain ();
Main.name = "Welcome you:" + this.txtName.Text;
Main. Show ();

public string name;
private void Frmmain_load (object sender, EventArgs e)
{
This. Text = name;
}

Initial Windows system

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.