The new cognitive WinForm form program

Source: Internet
Author: User

There are a lot of differences between Windows applications and console applications

Form1.cs: Form files, the code that programmers write to forms is typically stored in this file.

Form1.Designer.cs: Form design file, where the code is automatically generated by Visual Studio and is generally not required to be modified.

Form1.resx: A resource file that configures resources such as strings, pictures, and so on, used by the current form.

"Program.cs: Main program file, which contains the main () method of the program entry

partial has more than one partial in front of the form class. Partial is "partial" meaning, in C #, in order to facilitate the management and editing of code,

You can use the partial keyword to separate code for the same class into multiple files. Each file is part of the code for the class, called the distribution class. When code is compiled,

The compiler then merges the code of each distribution class together to process it.

The form is. Netframwork defines a most basic form class with some of the most basic properties and methods of a form, a colon representing inheritance, and a form that we create inherits from the form class.

then he has the form class, then it has the properties and methods in the form class, and then it is easy to understand the main properties and methods of the form.

Background image for The border style displayed by the Text displayed in the title bar of the
main properties of form
Name the name of the form object to identify in code
BackColor form background color
backgroundimage form
formborderstyle form has 7 optional values and defaults to sizable
MaximizeBox Determines whether the upper-right corner of the title bar has a maximum box value and defaults to True
ShowInTaskbar Determines whether the form appears in the Windows taskbar, default to true 
startposition determines where the form first appears
text form
Topmost Indicates whether the form always appears above all forms that are not set to true on the property, and defaults to False
WindowState determines the initial visual state of a form, including normal, maximized (maximized), minimized (minimized), and default to normal
   
Main methods of the form
Close () Close the form

Show ()

Show form
ShowDialog () Modal Display Form
Hide () Hide Form

FormBorderStyle is used to set the border style of a form, and if you do not want the form to run, the user will resize the form by dragging the mouse

To set the FormBorderStyle property value of a form to FixedSingle

"" Basic control

Label: used to display text or images that the user cannot edit

Image to display on the form

Text that is displayed on the form

Text box: Used to get information entered by the user or text to be displayed to the user

"MaxLength indicates the maximum number of characters that can be entered in the text box

"MultiLine indicates whether multiple lines of text can be entered in the text box

"PasswordChar indicates the characters that appear in the text box as the Password box, not the actual text entered

"ReadOnly indicates whether text in the text box is allowed to be edited

Text associated with the text box

Combo box: It combines text boxes and list boxes to allow users to enter text in a combo box, or to select from a list

Items in the Items combo box

"DropDownStyle defines the style of the combo box, indicating whether the list box section is displayed, whether the user is allowed to edit the text box part

Text associated with the combo box

SelectedIndex the index number of the currently selected item, each item in the list box has an index number, starting with 0

"SelectedItem Gets the currently selected item

"__ Event in combo box:

"Click to occur when the standalone control

"SelectedIndexChanged occurs after the SelectedIndex property has been modified

Button: Allows the user to perform actions via a single machine

"Enable Boolean value to indicate whether the control is available, true to be available, false to be unavailable, if the control is not available, and is grayed out after running

Text that appears on the text button

The alignment of text on the TextAlign button

The events in the ___ button

"Click to occur when the standalone control

Tip: When you name a control, you follow a specification that compares the generic specification: the abbreviation for the control class name + the English word with meaning.

The Eg:button control is abbreviated as BTN, then the login button can be named Btnlogin

Control's Common properties: Text, Name, enable, and so on, which are represented in the same way in different controls.

"" MessageBox message Box

In WinForm, a message box is a MessageBox object. So how do you create a message box? This requires the show () method of the MessageBox.

Eg:

message box with caption, button, icon

MessageBox.Show (string to display, message box caption, message box button, message box icon)

Tip: When judging an empty string, string. What is the difference between empty and null?

Answer: String. Empty represents the null string, that is, the string object contains no characters, and NULL represents a null reference, that is, no object is referenced.

Data transfer between forms of the ""

"Defines a public variable in the Test class Name

 Public string Name;

"is assigned to name in the login form (after assigning a value to name , it can be called in any class)

Test.name = txtName.Text;

"In the Change Password form to reference the value of Name

Newname.text = Test.name;

More exciting, please expect ~

The new cognitive WinForm form program

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.