21. Text Box control
The textbox is the most common and simplest text display and input control.
1. Common Properties.
The A.text property. The text displayed, set the text alignment by TextAlign.
The B.backcolor property. Sets the background color of the text box.
C.forecolor property to set the foreground color of the text box.
D.font property to set the properties of the font.
E.passwordchar property, the letter entered will be masking by the specified word.
The f.enable and visible properties.
The G.readonly property, whether read-only.
H.multiline property, whether it contains more than a row.
2. Common methods.
A.clear method, clear the text in the text box.
B.appendtext method, append text at the end of the text.
3. Common events.
A.textchanged event. The event is triggered when the content of the text changes.
The B.enter event, which triggers the event when the text box gets the focus.
The C.leave event, when the text box loses focus, triggers the event.
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Windows.Forms;
Namespace WindowsFormsApplication6
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}
private void textBox1_TextChanged (object sender, EventArgs e)
{
This.label1.Text = This.textBox1.Text;
}
private void Textbox2_textchanged (object sender, EventArgs e)
{
}
private void Form1_Load (object sender, EventArgs e)
{
This.textBox1.ForeColor = Color.Blue;
This.textBox1.BackColor = Color.White;
This.textBox2.ForeColor = Color.green;
This.textBox2.BackColor = Color.White;
This.textBox2.ReadOnly = true;
}
private void TextBox1_Enter (object sender, EventArgs e)
{
This.textBox1.Clear ();
}
private void Textbox1_leave (object sender, EventArgs e)
{
This.textBox2.AppendText (This.textBox1.Text + Environment.NewLine);
}
}
}
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/60/0D/wKiom1Uqd-GhBXKhAACqBtOihA0337.jpg "title=" S ' U] 5i43l}{z_x ' V{v2w0wn.png "alt=" Wkiom1uqd-ghbxkhaacqbtoiha0337.jpg "/>
This article from "Very blog" blog, reproduced please contact the author!
C # Self-study path