DBGrid组件有一个事件OnDrawColumnCell,begin if Table1.FieldByName('size').AsInteger>=40 then begin DBGrid1.Canvas.Font.Color:=clred; DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end; if (Table1.FieldByName('size').AsInteger>=30) and (Table1.FieldByName('size').AsInteger<40) then begin DBGrid1.Canvas.Font.Color:=clBlue; DBGrid1.DefaultDrawCloumnCell(Rect,DataCol,Column,State); end; if (Table1.FieldByName('size').AsInteger>=20) and (Table1.FieldByName('size').AsInteger<30) then begin DBGrid1.Canvas.Font.Color:=clYellow; DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end; if (Table1.FieldByName('size').AsInteger)>=10 and (Table1.FieldByName('size').AsInteger<20) then begin DBGrid1.Canvas.Font.Color:=clLime; DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State); end; end; 你试试吧!
if Table1.FieldByName('size').AsInteger>=40 then
begin
DBGrid1.Canvas.Font.Color:=clred;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
if (Table1.FieldByName('size').AsInteger>=30) and (Table1.FieldByName('size').AsInteger<40) then
begin
DBGrid1.Canvas.Font.Color:=clBlue;
DBGrid1.DefaultDrawCloumnCell(Rect,DataCol,Column,State);
end;
if (Table1.FieldByName('size').AsInteger>=20) and (Table1.FieldByName('size').AsInteger<30) then
begin
DBGrid1.Canvas.Font.Color:=clYellow;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
if (Table1.FieldByName('size').AsInteger)>=10 and (Table1.FieldByName('size').AsInteger<20) then
begin
DBGrid1.Canvas.Font.Color:=clLime;
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
你试试吧!