DbGridEh根據某一個字段的值顯示對應底色或字體變化


改變行底色:
procedure TForm1.dggrideh1DrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
    if(adqry.FieldByName('status').AsBoolean) then
    begin
       dggrideh1.Canvas.Brush.Color:=clRed;         //行底色變色
       dggrideh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
end;
改變行字體顏色:
procedure TForm1.dggrideh1DrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
    if(adqry.FieldByName('status').AsBoolean) then
    begin
       dggrideh1.Canvas.Font.Color:=clMaroon;     //行字體變顏色
       dggrideh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
end;

 

 參考:ide

https://bbs.csdn.net/topics/360262293字體

相關文章
相關標籤/搜索