TextBoxes in C#


Text boxes should be used whenever you want users to enter text that you have no knowledge of at design time.

The primary function of a text box is for users to enter text, but any characters can be entered.

TextBox Properties


CharacterCasing A value indicating whether the TextBox changes the case of the text entered. 

• Three values are possible:
– Lower: All text entered is converted to lowercase.
Normal: No changes are made to the text.
Upper: All text entered is converted to uppercase.


  • MaxLength: A value that specifies the maximum length, in characters, of any text entered into the TextBox.

  • ReadOnly: A Boolean indicating whether the text is read-only.
  • Multiline: Indicates whether this is a multiline control, meaning it is able to show multiple lines of text. When Multiline is set to true, you’ll usually want to set WordWrap to true as well.
  • PasswordChar: Specifies whether a password character should replace the actual characters entered into a single-line TextBox. If the Multiline property is true, then this has no effect.
  • ScrollBarsGets or sets which scroll bars should appear in a multiline TextBox control.
  • Text: Gets or sets the current text in the TextBox 
  • TextAlignGets or sets how text is aligned in a TextBox control.
  • SelectedText: The text that is selected in the TextBox.
  • SelectionLength: The number of characters selected in the text.
  • SelectionStart: The start of the selected text in a TextBox.
  • WordWrap: Specifies whether a multiline TextBox should automatically wrap words if a line exceeds the width of the control.

No comments:

Post a Comment