Partager via


MaxLength Property

Specifies the maximum length in characters that can be entered in an EditBox, TextBox, or ComboBox control. For these controls, use MaxLength to limit the amount of text a user can enter in an edit box, text box, or combo box.

For XMLField objects, MaxLength specifies the total length of the Character or Numeric field in a cursor when using the XMLTableToCursor method or in an XML schema when using the XMLAdapterToXML method.

Available at design time and run time.

Control.MaxLength [= nMaxLength]

-or-

XMLField.MaxLength [= nMaxLength]

Property Values

  • nMaxLength
    Specifies the maximum number of characters that can be entered in an edit box, text box, or combo box.

    When nMaxLength is set to 0, there is no limit to the number of characters that can be entered into an edit box. For text and combo boxes, the size of the text or combo box and its data type determines the number of characters that can be entered.

    For XMLField objects, MaxLength for Memo fields is 2147483647. For Numeric, Float, and Double fields, MaxLength is the same as XML facet totalDigits+1.

Remarks

For text or combo boxes, MaxLength applies only when set to a value greater than 0, and the control does not use the InputMask property. For combo boxes, MaxLength is significant only when Style is set to 0 and applies only to the text box portion of the combo box. The Value property of the text box must be of Character type; however, the Value property of a combo box can be other types, such as Numeric.

If the ControlSource property of a control is bound to a field, Visual FoxPro truncates any characters entered that exceed the length of the field.

See Also

Properties | ToCursor Method | ToXML Method | InputMask Property | Value Property | Style Property | ControlSource Property | SelLength Property

Applies To: ComboBox | EditBox | TextBox | XMLField Class