Home » .Net » C#.Net » C#.Net Windows Development

TextBox.MaxLength Property with Example in C#.Net

C#.Net - TextBox.MaxLength Property with Example: Here we are going to learn about the MaxLength property of TextBox Control in C#.Net Windows Application Development.
Submitted by IncludeHelp, on September 03, 2018

Here we are demonstrating use of MaxLength property of TextBox.

MaxLength property of TextBox is used to set maximum number of character that we can input into a TextBox. Limit of MaxLength property is 1 to 32767. By default this property is set to 32767.

Example:

TextBox.MaxLength Property 1

In this example, we took a Windows form that contains a TextBox named txtInput, we are setting MaxLength to 4, that means we cannot enter character more than 4 in this TextBox.

TextBox.MaxLength Property 2

Change the property using code:

private void Form1_Load(object sender, EventArgs e)
{
	textInput.MaxLength = 4;
}


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.