TCustomEdit.NumbersOnly property
Indicates if the edit control accepts numeric values only.
Declaration
property NumbersOnly: Boolean read GetNumbersOnly write SetNumbersOnly default False;Description
NumbersOnly is a
Boolean property which controls
whether Text is limited to characters which represent numeric digits. The
default value for the property is
False, and allows any character
valid for the type to be entered. When set to
True, only the
characters '0'..'9' are accepted in Text. '+', '-', ',', and '.' are
not numeric digits.
Changing the property value causes the widgetset class to be notified when a handle has been allocated for the control.
NumbersOnly is used in CreateParams to include the
ES_NUMBER edit style in the creation parameters for the control when
set to True.
NumbersOnly is not supported on all platform for the LCL; GTK 2 does not support the property.
Versions of Windows prior to Windows 95 did not enforce the ES_NUMBER style flag. It could be specified, but still allowed any value to be manually entered into the edit control. Some version of Windows allowed copy (Ctrl+C) and paste (Ctrl+V) to be used to insert non-numeric values - even when NumbersOnly is set to True.
For inputs that require both numeric and punctuation digits, use one of the keyboard event handlers like OnKeyPress or OnKeyDown to filter values as they are entered into a control. Or, use TMaskEdit which supports using an edit mask for the input values.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
