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