DBGRID中,如何将TABLE或QUERY中满足条件的行用特别颜色显示(100分)

  • 主题发起人 主题发起人 sangzh
  • 开始时间 开始时间
S

sangzh

Unregistered / Unconfirmed
GUEST, unregistred user!
DBGRID中,如何将TABLE或QUERY中满足条件的行用特别颜色显示,能否示例?
 
//这样的问题都问烂了。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
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.DefaultDrawColumnCell(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;

end.
 
谢谢,新手上路请多指教!
 
对,同意mlzhou, 的
 
同意mlzhou的
 
后退
顶部