Page Stats
Visitor: 9
C#.Net Textbox
C#.Net TextBox control is used to display, or accept input from user. Provide the user with an area to write/edit text.
Attributes | Description |
---|---|
AutoCompleteCustomSource | To use when the AutoCompleteSourceproperty is set to Custom Source. |
AutoCompleteMode | Options that controls how automatic completion works for the TextBox. |
BackColor | To change textbox background color. |
BorderStyle | You can set 3 different types of border style i.e. None, FixedSingle and fixed3d |
CharacterCasing | Use to modify the case of characters as they are typed. |
Enabled | Set to false to make the text box read-only. |
Font | Change the font of the text displayed by the control. |
ForeColor | Change the foreground color of the control. |
MaxLength | Set the maximum length for the text in the control. |
Multiline | To change the textbox from single line to multi line mode. |
PasswordChar | Generally use to enter passwords. |
Readonly | Tells whether the text in the form can be edited. |
RightToLeft / TextAlign | To change the alignment of the textbox. eg Left, Center, Right. |
ScrollBars | Specify how scroll bars should appear in a multiline TextBox control. None, Horizontal, Vertical, Both. |
TabIndex | Specify the tab order of the control. |
Text | Specify the text display in the text box. |
Visible | Tells whether the text box is visible inside the form. |
WordWrap | Automatically transfer cursor to the next line. |
Height/Width | To change textbox height and width. |
Attributes | Description |
---|---|
AppendText | Appends text to the current text of a text box. |
Clear | Clears all text from the text box control. |
Copy | Copies the current selection in the text box to the Clipboard. |
Cut | Moves the current selection in the text box to the Clipboard. |
Paste | Replaces the current selection in the text box with the contents of the Clipboard. |
ResetText | Resets the Text property to its default value. |
Undo | Undoes the last edit operation in the text box. |
Attributes | Description |
---|---|
Click | When the control is clicked. |
DoubleClick | When the control is double-clicked. |
Enter | Control got focus or active. |
Leave | Control lost focus or no longer active. |
KeyDown, KeyPress, KeyUp | Keyboard Events. |
MouseDown, MouseEnter, MouseHover, MouseLeave, MouseMove, MouseUp | Mouse Events. |
TextChanged | Event raised when the value of the text changed. |
Validated | |
Validating |
Example 1: Identify the key pressed.
private void textBox1_keydown(object sender, keyEventArgs e) { if(e.KeyCode == Keys.Enter) { MessageBox.Show("You Press Enter Key"); } }
Example 2: Display Text in Label while changing in textbox.
