Specifies the maximum length in characters that can be entered in an EditBox, TextBox, or ComboBox control. For XMLField objects, MaxLength specifies the total length of the Character or Numeric field in a cursor when using the XMLTableВ ToCursor method or in an XML schema when using the XMLAdapterВ ToXML method. Available at design time and run time. There are two versions of the syntax.
Control.MaxLength [= nMaxLength] |
XMLField.MaxLength [= nMaxLength] |
Return Value
- 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
Applies To: ComboBox | EditBox | TextBox | XMLField Class
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.