I. Application.exit () and this. The difference between Close ()
Application.exit ()
1. Application class Application static method for exiting the current application
2. If more than one form is open for the current application, close all forms
3. Fromclising and formclosed events for forms are not triggered when the form is closed
This. Close ()
1. Instance method, which closes the current form if the current form is a system-initiated form, the entire application exits after the method form is executed
2. If more than one form is open for the current application, only the current form is closed
3. The fromclising and formclosed events of the form are triggered when the current form is closed
Two. ToolStrip and MenuStrip controls
2.1 Main properties of a menu control
Name of the menu object in the name code
Items display a collection of items in a menu
Text associated with the menu item
2.2 Main properties and events for menu items
The Name code in the menu item object, forming
DropDownItems A collection of items displayed in a submenu
Text associated with the menu item
Click to trigger the event when the menu item is selected
2.3 Main properties in the toolbar
Imagescalingsize the size of an image displayed by an item in the toolbar
Items display a collection of items on the toolbar
2.4 Main properties and time of buttons and labels on the toolbar
Dispalystyle set how images and text are displayed, including displaying text, displaying images, displaying images and text, or displaying nothing
Images displayed on the image button/label
Imagescaling whether the button is adjusted. The size of the picture displayed on the label
Text displayed on the Text button/label
Textimagerelation button. The relative position of the label like the text
Click the button to trigger the event when the label is clicked.
Three. How controls are arranged
Anchor
Dock
Four. Setting up an MDI form
1. The IsMdiContainer property of the parent form is set to True
2. The MdiParent property of the subform is set to the parent form
ChildForm childform = new ChildForm ();
Childform.mdiparent = this;
Childform.show ();
Five. Binding the drop Box data
Methods that are executed before the form show ()
private void Frmeditstudent_load (object sender, EventArgs e)
{
1. Create a database connection string
String constr = "Data source=.;i Nitial Catalog=schooldb; User=sa; Pwd=. ";
2. Create a Connection object connection
SqlConnection con = new SqlConnection (CONSTR);
Try
{
3. Open the database connection
Con. Open ();
4. Create SQL
String sql = "SELECT * from Grade";
5. Create a Command object to send a request
SqlCommand cmd = new SqlCommand (Sql,con);
SqlDataReader Dr=cmd. ExecuteReader ();
if (Dr. HasRows) {
while (Dr. Read ()) {
How to bind to a drop-down box
THIS.CBOGRADE.ITEMS.ADD (dr["Gradename"]);
}
}
}
catch (Exception x)
{
MessageBox.Show (X.tostring ());
}
finally {
Con. Close ();
}
The first item is selected by default
This.cbograde.SelectedIndex = 0;
}
Build a well-laid Windows program