WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStWidget class reference

SetMaxLength

Sets maximum number of characters that can be typed on a WS_FIELD widget.

Ole declaration

VARIANT_BOOL SetMaxLengthByName(LPCTSTR sObjectName, SHORT usMaxLength);

VARIANT_BOOL SetMaxLengthById(SHORT usObjectId, SHORT usMaxLength);

Parameters
sObjectName
The name of the target widget.
usObjectId
The id of the target widget.
usMaxLength
The maximum number of characters allowed to type on this widget. If this parameter is 0, unlimited characters can be typed.
Return Value

On success, SetMaxLength returns TRUE, FALSE otherwise. To get extended information, call WStError::GetLastErrorCode.

Remarks

The limit set by this method doesn't apply to the scanner input.

Once the maximum number of characters is reached and the length control mode WS_FIELD_LC_NO_RETURN_ON_FILL is not set (using ModifyLenCtrlMode) the input is processed and sent to the server. The widget triggers an event and GetEvent returns.

Example
C#
using WirelessStudioOleWidgets;
WStWidget oWidget = new WStWidget();
WStFactory oFactory = new WStFactory();
short iFieldId = 33;
oFactory.CreateWidgetById((short)WSTFactoryConstants.WS_FIELD, iFieldId, "", 0,0, 50, 50, "123");
oWidget.SetMaxLengthById(iFieldId, 3);
Visual Basic 6 (Full Example: FieldDemoModule.bas.txt)
Public wsWidget As New WStWidget
...
Case "maxLengthField"
		iMaxLength = wsForm.GetLastEventStrValue()
		wsWidget.SetMaxLengthByName "field", iMaxLength
...
See also

ModifyInputMode | ModifyDisplayMode | ModifyInputDevices | ModifyLenCtrlMode | SetScannerConfigFile | SetKeyboardMode | GetLastInputType | GetLastBarcodeType

WStWiget class reference | WStForm class reference | WStFactory class reference | WStError class reference