sgsx是个6*6的矩阵,要实现的功能是判断sgsx里哪个单元格内容和数组内容一样,一样的话则改变此单元格的背景色和文字颜色
代码:
procedure Tfrmjzfx.sgsxDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var numi:integer;
strchr:string;
begin
for numi:=0 to 5 do
begin
strchr:=allvar.h[numi];
if strtoint(strchr)=strtoint(sgsx.Cells[acol,arow]) then
begin
rect:=sgsx.CellRect(acol,arow);
sgsx.Canvas.Brush.Color :=clred;
sgsx.Canvas.FillRect(rect);
sgsx.Canvas.Font.Color :=clwhite;
sgsx.Canvas.TextOut(rect.Left ,rect.Top ,strchr);
end;
end;
end;运行后弹出错误提示,大意是’即单引号不是一个合法的整形变量,但是可以看到sgsx里已经正确输出显示了。何解?
代码:
procedure Tfrmjzfx.sgsxDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var numi:integer;
strchr:string;
begin
for numi:=0 to 5 do
begin
strchr:=allvar.h[numi];
if strtoint(strchr)=strtoint(sgsx.Cells[acol,arow]) then
begin
rect:=sgsx.CellRect(acol,arow);
sgsx.Canvas.Brush.Color :=clred;
sgsx.Canvas.FillRect(rect);
sgsx.Canvas.Font.Color :=clwhite;
sgsx.Canvas.TextOut(rect.Left ,rect.Top ,strchr);
end;
end;
end;运行后弹出错误提示,大意是’即单引号不是一个合法的整形变量,但是可以看到sgsx里已经正确输出显示了。何解?
才导致strtoint(strchr)出现单引号错误吧.