I am using a TMSFNCGrid in a VCL application, and my decimal separator is ','
Is there a way to have the behaviour of ExcelStyleDecimalSeparator of TMS VCL AdvStringGrid, to convert numeric keypad decimal '.' to default decimal separator (',' in my case) ?
Thank you
The grid works with the FormatSettings, so changing the DecimalSeparator should be done with FormatSettings.DecimalSeparator. There is no grid specific option for that.
I'm sorry, but ExcelStyleDecimalSeparator is specific to one keyboard key VK_DECIMAL (decimal point on the numeric keyboard) while FormatSettings change the separator char. It's like the difference between OnKeyPress and OnKeyDown: Keyboard key vs char.
This problem is often resolved with OnKeyDown event, but Editing property returns false despite the fact that the cell is in edit mode!
Thank you Pieter. If it helps someone who uses numbers a lot and has the same problem, here is what I did to get around it:
Check KeyPreview on the form (container of TMSFNCGrid)
Add a new variable on the private part of the form:
private
FEditKey: Char;
Make methods OnKeyDown and OnKeyPress as :
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
FEditKey := #0;
if (Key = VK_DECIMAL) then
FEditKey := FormatSettings.DecimalSeparator;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (FEditKey <> #0) and (ActiveControl is TTMSFNCGridEdit) then
if FncGrid.GetFocusedColEditor in [etFloatEdit, etSignedFloatEdit, etMoneyEdit] then
Key := FormatSettings.DecimalSeparator;
end;
The goal is to correct the decimal symbol on Numeric Keypad, into float cells only, and not to disturb the classic . elsewhere, and independently of FormatSettings.