1, the MDI form is equipped with two forms frmmain, frmChild, then: frmmain: Set the ismdicontainer property to True Open Subside: Write the following code in related events: frmChild child = new fmChild (); child.mdiparent = this; // This means that the form is a parent form Child.show (); when a child form is opened, if only one sub-form is allowed, it can be judged: if (this.activemdichild! = null) {THIS .Activemdichild.close (); // Close the open subsidy // ....} Change the MDI main form background first declare a form object private system.windows.forms.mdiclient m_mdiclient; in Form_Load and other incidents Add the following code: int icnt = this.controls.count; for (int i = 0; i // Note path proc.startinfo.arguments = ""; proc.start (); // Get the current directory Directory.getCurrentDirectory () (Using System.IO) 6, Toolbar Using Toolbar control usually requires the imagelist control (need Used in it) Response Toolbar Click Event Processor Code: Switch (ToolBarname.Buttons.Indexof (E.Button) {CASE 0: // First Buttons // Code ... Break; Case 1: // The second button // code ... Break; // Other case code default: // Default, but all items are not compliant // code ... break;} 7, pop-up dialog Get related return values Run the following code in the form of the form, you can ask DialogResult results when the user closes the form, is it true to turn off the window? "," Close prompt ", MessageBoxButtons.okcancel, MessageBoxicon. Question; if (result == DialogResult.ok) {// Close window E.cancel = false;} else {// Cancel close E.CANCEL = true;} 8, print control requires two controls PrintDocument PrintPreviewDialog: Preview dialog box, with the need to use PrintDocument, i.e. corresponding to the document property set printpage printDocument printdocument event (the print preview or event handler) code must float fltHeight = 0;. float fltLinePerPage = 0; long lngTopMargin = e.MarginBounds.Top INT INTCOUNT = 0; String Strline; // Calculate the number of rows that can be accommodated per page to determine when florinbounds.height / txtprintText.Font.getHeight (E.Graphics); while ((strline = streamtoprint.readline ())! = null) && (intCount New system.io.text; printpreviewDialogname.showdialog (); 9, String object Essent with StringBuilder class, string uses String object is an uncharged type, when we modify a String object, one will produce one New String object, so when you need to change the character object to change, it is recommended to use the StringBuilder class: [Sample code] constructed a query string StringBuilder SB = New StringBuilder ("" "," SB.Append ("Select * from Employees Where" ); sb.append ("ID = {0} and"); sb.append ("Title = '{1}'"); string cmd = sb.tostring (); sb = null; // no longer need When it is empty it cmd = string.format (cmd, txtid.text, txttile.text); // Decorate whether the string is empty with the actual value of the format: Check if a string is empty or not a basic programming requirement An effective way is to replace NULL or "" comparison using the length attribute of the String class. Comparison string: Use string.equals method to compare two string string str1 = "fRText"; if (str1.equals ("teststing") {// do something} 10, determine if a string is in another Several methods for use in string (arrays) String.Split (char); // According to CHAR, return to the array.indexof (Array, String): Returns the first String in Array The subscript subscript Array.lastIndexOf (Array, String): Returns the last match of the last match in Array If there is no match, return -1 [sample code]: String Strnum = "001,003,008"; String [] stratay = strnum.split (','); // Press comma to split, split characters as a char or char array console.Writeline (strarm, "004"). TOSTRING ()); 11 After the map of the DataGrid and the table and columns are bound to the database from the database to the DataGrid, the DataGrid's column header is usually the same as the field name of the database. If it is not desirable, then the mapping technology of the table and columns can be used: USING SYSTEM. Data.Common; string strSql = "select * from department"; OleDbDataAdapter adapter = new OleDbDataAdapter (strSql, conn); DataTableMapping dtmDep = adapter.TableMappings.Add ( "department", "the department table"); dtmDep.ColumnMappings.Add ( "DEP_ID", "Department Number"); DTMDEP.COLumnMAppings.add ("DEP_NAME", "Department Name"); Dataset DS = New Dataset (); Adapter.Fill (DS, "Department"); // Can't Use "department table" to respond to the event (DataGrid's currentcellchanged event) dataGridname.currentcell.columnnumber; // click column The subscript, starting from 0, the following DataGridname.currentcell.rownumber; // The subscript DATAGRIDNAME [DATAGRIDNAME.CURRENTCELL] of the click line is DataGridName [DataGridName.currenTrowIndex, n]. TOSTRING (); // Get the value 12 of the row N 1 column, dynamically add menu and add a top-level menu to it: mainmenuname.MenuItems.Add ("Top Menu 1); // Each addition automatically added at the back of the secondary menu: MenuItem mniItemN = new MenuItem ( "MenuItemText") MenuItem mniItemN = new MenuItem ( "MenuItemText", new EventHandler (EventDealName)) MainMenuName.MenuItems [n] .MenuItems.Add (mniItemN); // n When the top-level menu to be added, then add an event from 0 to the 0: mniitemn.click = new eventhandler (EventdealName);