delphi 的stringgrid问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 01:45:15
procedure TF_diagnosis.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
grow:integer;
begin
if i=1 then
begin
if (ACol=3) then
begin
StringGrid1.Canvas.Font.Color := clred; //字体颜色为红的
//StringGrid1.Canvas.Brush.color:=clMoneyGreen; //背景为 美元绿色
StringGrid1.Canvas.FillRect(Rect);
end;
执行之后
单元格中的字都看不见了。
怎么解决
end;
end;
怎么调整

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
grow:integer;
i:integer;
begin
//if i=1 then
begin
if (ACol=3) then
begin
StringGrid1.Canvas.Font.Color := clred; //字体颜色为红的
//StringGrid1.Canvas.Brush.color:=clMoneyGreen; //背景为 美元绿色
StringGrid1.Canvas.FillRect(Rect);
//加上这句话就可以了
StringGrid1.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);

end;
//执行之后
//单元格中的字都看不见了。
//怎么解决
end;
end;

要么调整字体为反白, 要么调整你绘的颜色!