c#中textbox屬性
Here we are demonstrating use of MaxLength property of TextBox.
在這里,我們演示了TextBox的MaxLength屬性的使用。
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.
TextBox的MaxLength屬性用于設置可以輸入到TextBox中的最大字符數。 MaxLength屬性的限制為1到32767 。 默認情況下,此屬性設置為32767 。
Example:
例:
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.
在此示例中,我們采用了Windows窗體,其中包含一個名為txtInput的TextBox ,我們將MaxLength設置為4 ,這意味著我們不能在此TextBox中輸入超過4個字符。

Change the property using code:
使用代碼更改屬性:
private void Form1_Load(object sender, EventArgs e)
{
textInput.MaxLength = 4;
}
翻譯自: https://www.includehelp.com/dot-net/textbox-maxlength-property-with-example.aspx
c#中textbox屬性