I have a StringGrid with the column 1 centered.
procedure TfrmMain.myGridPrepareCanvas(sender: TObject; aCol,
aRow: Integer; aState: TGridDrawState);
var
MyTextStyle: TTextStyle;
begin
if (aRow >= myGrid.FixedRows) then begin
if (aCol = 1) then begin
MyTextStyle.Alignment := taCenter;
myGrid.Canvas.TextStyle := MyTextStyle;
end else if (aCol = 4) then begin
MyTextStyle.Alignment := taRightJustify;
myGrid.Canvas.TextStyle := MyTextStyle;
end;
end;
end;
That grid has only 1 row, the header. The user add new rows with data. The column 1 contains the number of the new row: '001', '002', etc. and at times '00+'. But when a row with column 1 of '00+' is added, so the grid shows '+00' instead. In order to correct this I changed '00+' to '[00+]', but the error continues, the grid shows me '[+00]'. But numbers ar showed correctly: '001', '002', etc.
procedure TForm1.btnAddFilaClick(Sender: TObject);
begin
With myGrid do
begin
RowCount := RowCount + 1;
Cells[1, 1] := '[00+]';
Cells[2, 1] := Edit1.Text;
Cells[3, 1] := Edit2.Text;
end;
end;