Am having a string grid(TStringGrid
) with 2 column and 1 row (Property: ColCount = 2 & Rowcount = 1
.
Code for OnDrawCell
Event:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Parametertext : string;
begin
case ACol of
0 : Parametertext := 'Test';
1 : Parametertext := 'Test1';
end;
stringgrid1.Brush.Color := clBtnFace;
stringgrid1.Font.Color := clWindowText;
stringgrid1.Canvas.FillRect(Rect);
DrawText(stringgrid1.Canvas.Handle, PChar(parameterText), -1, Rect,
DT_SINGLELINE);
end;
When I run the application, I get the below output:
Question:
When I try to get the text using StringGrid1.Cells[0,0]
, StringGrid1.Cells[1,0]
,
I except "Test" & "Test1" but it always gives a empty string"".
How can I get the text from string grid using StringGrid.Cells[aCol,aRow]
?