Textbox Control

Textbox Control

Text box controls allow entering text on a form at runtime. By default, it takes a single line of text, however, you can make it accept multiple texts and even add scroll bars to it.

Property :

  1. TextAlign :- Gets or sets how text is aligned in a TextBox control.
  2. Multiline: – Gets or sets a value indicating whether this is a multiline TextBox control.
  3. MaxLength :- Gets or sets the maximum number of characters the user can type or paste into the text box control.
  4. HideSelection :- Gets or sets a value indicating whether the selected text in the text box control remains highlighted when the control loses focus.
  5. PasswordChar:- Gets or sets the character used to mask characters of a password in a single-line.
  6. TextLength :- Gets the length of text in the control.
  7. WordWrap :- Indicates whether a multiline text box control automatically wraps words to the beginning of the next line when necessary.

Method :

1. AppendText : Appends text to the current text of a text box. 

You can use this method to add text to the existing text in the TextBox control instead of using the concatenation operator (+). It works faster when content of text is more.

For example, adds the text OM to the existing text of the textbox1.

TextBox1.AppendText(“OM”)

2. Clear :Clears all text from the text box control. 

For example, to clear all the contents of the text box1,

TextBox1.Clear()

3. Copy: This method Copies the selected text from the TextBox control to the Clipboard.

For example, to copy the selected text from the TextBox1 to the Clipboard,

TextBox1.Copy()

4. Cut: This method removes (Moves) the selected text from the TextBox control to the Clipboard.

For example, to removes (Moves) the selected text from the TextBox1 to the Clipboard,

TextBox1.Cut()

5. Paste: This method replaces the selected text in the TextBox with the text from the Clipboard.

TextBox1.Paste()          

6. SelectAll: This method is used to Selects all text in the text box.

TextBox1.SelectAll()

Event :

1. TextChanged : This is the default event of the Textbox control. It is triggered (fires or executes)when the text in the TextBox is changed.

Leave a Comment