ToolStripTextBox.MaxLength ToolStripTextBox.MaxLength ToolStripTextBox.MaxLength ToolStripTextBox.MaxLength Property

Definición

Obtiene o establece el número máximo de caracteres que el usuario puede escribir o pegar en el control de cuadro de texto.Gets or sets the maximum number of characters the user can type or paste into the text box control.

public:
 property int MaxLength { int get(); void set(int value); };
public int MaxLength { get; set; }
member this.MaxLength : int with get, set
Public Property MaxLength As Integer

Valor de propiedad

Número de caracteres que pueden escribirse en el control.The number of characters that can be entered into the control. El valor predeterminado es 32767 caracteres.The default is 32767 characters.

Ejemplos

En el ejemplo de código siguiente se muestra la sintaxis ToolStripTextBox para establecer diversos valores de propiedades MaxLength comunes, incluida la propiedad.The following code example demonstrates the syntax for setting various ToolStripTextBox common property settings, including the MaxLength property .

// This code example demonstrates the syntax for setting
// various ToolStripTextBox properties.
// 
toolStripTextBox1.AcceptsReturn = true;
toolStripTextBox1.AcceptsTab = true;
toolStripTextBox1.AutoCompleteCustomSource.AddRange(new string[] {
"This is line one.",
"Second line.",
"Another line."});
toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
toolStripTextBox1.HideSelection = false;
toolStripTextBox1.MaxLength = 32000;
toolStripTextBox1.Name = "toolStripTextBox1";
toolStripTextBox1.ShortcutsEnabled = false;
toolStripTextBox1.Size = new System.Drawing.Size(100, 25);
toolStripTextBox1.Text = "STRING1\r\nSTRING2\r\nSTRING3\r\nSTRING4";
toolStripTextBox1.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
' This code example demonstrates the syntax for setting
' various ToolStripTextBox properties.
' 
toolStripTextBox1.AcceptsReturn = True
toolStripTextBox1.AcceptsTab = True
toolStripTextBox1.AutoCompleteCustomSource.AddRange(New String() {"This is line one.", "Second line.", "Another line."})
toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource
toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
toolStripTextBox1.HideSelection = False
toolStripTextBox1.MaxLength = 32000
toolStripTextBox1.Name = "toolStripTextBox1"
toolStripTextBox1.ShortcutsEnabled = False
toolStripTextBox1.Size = New System.Drawing.Size(100, 25)
toolStripTextBox1.Text = "STRING1" + ControlChars.Cr + ControlChars.Lf + "STRING2" + ControlChars.Cr + ControlChars.Lf + "STRING3" + ControlChars.Cr + ControlChars.Lf + "STRING4"
toolStripTextBox1.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center

Comentarios

Puede usar esta propiedad para restringir la longitud del texto escrito en el control para valores como códigos postales y números de teléfono, o para restringir la longitud del texto introducido cuando los datos se van a escribir en una base de datos.You can use this property to restrict the length of text entered in the control for values such as postal codes and telephone numbers, or to restrict the length of text entered when the data is to be entered in a database. Puede limitar el texto escrito en el control a la longitud máxima del campo correspondiente en la base de datos.You can limit the text entered into the control to the maximum length of the corresponding field in the database.

Se aplica a