TcxCustomTextEditProperties.EditFormat Property
Determines the manner in which the editor’s text is formatted when the editor is focused.
Declaration
property EditFormat: string read; write;
Property Value
Type |
---|
string |
Remarks
The EditFormat and DisplayFormat properties control the way in which the editor displays its text when the editor is focused (in edit mode) and does not have focus (in display mode), respectively. If the EditFormat property is not specified, you can set the UseDisplayFormatWhenEditing property to True to select DisplayFormat for value formatting in edit mode. That way, you can unify the manner in which values are formatted in both modes, assigning only the DisplayFormat and UseDisplayFormatWhenEditing properties. If you assigned the EditFormat property, the DisplayFormat and UseDisplayFormatWhenEditing property values are ignored in edit mode.
Format strings depend upon the editor’s data type. Refer to the TNumericField.EditFormat property description to learn about numeric data format strings. To learn about date/time value format strings, refer to the SysUtils.DateTimeToString and SysUtils.StrToDate function descriptions.
Note that an editor automatically removes the thousand monetary separator when a validation is being performed. Deletion of a currency symbol must be performed manually, in order to prevent a runtime exception. For this purpose, handle the OnValidate event.
The following example shows how the currency symbol can be removed from the input:
// ...
procedure <TForm1>.<cxCurrencyEdit1Properties>Validate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
var
APos: Integer;
S: string;
begin
S := DisplayValue;
APos := AnsiPos('$', S);
Error := Error and (APos = 0);
if not Error then
Delete(S, APos, 1);
DisplayValue := S;
end;