TextBox Usage Summary:
1 Remove the Border "Note: this = TextBox" this. BorderStyle = System.Windows.Forms.BorderStyle.None;
2 Set font this. Font = new System.Drawing.Font (this. Font.Name, 11);
3 Set cursor this. Focus ();//cursor moves to the current TextBox this.selectall (); Select all content this. SelectionStart = this. text.length;///set cursor at the end
4 set size this. Size = new System.Drawing.Size (30, 25);
5 Sets the maximum number of characters this. MaxLength = 3; Up to a maximum of 3
6 add control, set control position Label lb = new label (); Controls.Add (lb);//Add a labellb.location = new System.Drawing.Point (10,10);
7 Set font centered this. TextAlign = HorizontalAlignment.Center;
8 Control input Content---Override textbox event protected override void OnKeyPress (KeyPressEventArgs e) { //block keyboard input E. Keychar.tostring () key character e.handled = true; if ((E.keychar >= ' 0 ' && e.keychar <= ' 9 ') | | (E.keychar = = (char) 8)) { //can only enter 0-9 e.handled = false; return;} }
C # TextBox Usage Summary