我有一个TStringGrid
带有 2 列和 1 行 ( Property: ColCount = 2 & Rowcount = 1
.
事件代码OnDrawCell
:
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;
问题:
当我尝试使用StringGrid1.Cells[0,0]
, StringGrid1.Cells[1,0]
,获取文本时
我除了“Test”和“Test1”,但它总是给出一个空字符串“”。
如何使用从字符串网格中获取文本StringGrid.Cells[aCol,aRow]
?