String Grid lazarus / 31-LCL ---------------------------------------------------------------------- Rodney · 2013-02-16 12:14 Hopefully this is a very simple question... I am displaying a % value in all of the columns of the Row 2 of my grid and so I want the format of the cells in that row to be <99.9 and displaying to 1 decimal place. I have used the OnGetEditMask event and my code is:     if ARow = 2 Then        Value:='99.9'; Everything compiles but all the values are still displaying to 7 decimal places! Is there something else that I should be doing? ---------------------------------------------------------------------- Blaazen · 2013-02-16 12:27 It has nothing to do with OnGetEditMask. StringGrid contains strings. I assune you have some routine where you fill the grid with data. You can do: Code: [Select]var f: Double; ... if f>99.9 then f:=99.9; Cells[2, y]:=FloatToStrF[f, ffFixed, 0, 1]; If user inserts data directly to cell (i.e. grid is not read-only), you can use any cell editor (TFloatSpinEdit should be fine). Or use OnEditingDone to correct inserted value immediately after editing. ---------------------------------------------------------------------- Rodney · 2013-02-16 13:12 Thanks very much Blaazen - that works fine.  What is OnGetEditMask used for? ---------------------------------------------------------------------- Bart · 2013-02-16 13:25 Can't you set an EditMask in OnGetEditor? (Too lazy to test myself obviously). Bart ---------------------------------------------------------------------- Blaazen · 2013-02-16 14:08 @ It has nothing to do with OnGetEditMask. I was NOT right. Your original code works well in case that data are manually edited. I tested this: Code: [Select]procedure TForm1.StringGrid1GetEditMask(Sender: TObject; ACol, ARow: Integer;   var Value: string); begin   Value:='99'+FormatSettings.DecimalSeparator+'9'; end;    Note that you have to add unit "clocale" to uses of *.lpr file to activate formatsettings.