如何设置?

解决方案 »

  1.   

    procedure TForm_Main.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
      with DBGrid1.Canvas do
      begin
        if 你的条件 then
          DBGrid1.Canvas.Brush.Color:= clBackground
        end;
       DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end;
      

  2.   

    procedure TFrmKhsf.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
     inherited;
      with DBGrid1 do
      begin
       if ((State = [gdSelected]) or (State=[gdSelected,gdFocused])) then
        begin
         Canvas.Font.Color :=ClYellow;
         Canvas.Brush.Color :=ClNavy;
        end
        else
        begin
          if  dmmain.ADOQKhsf.FieldByName('khbh').AsString='cw0001' then //条件
            Canvas.brush.Color :=ClYellow;       
        end;
        DefaultDrawColumnCell(Rect, DataCol, Column, State);// 这行很关键的,一定不要遗漏了
      end;if gdSelected in State then  //被选中行的颜色
      begin
        dbgrid.Canvas.Font.Color := clBlack;
        dbgrid.Canvas.Brush.Color :=selectedcolor;
        dbgrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      end;
      

  3.   

    如何,在DBGrid1DrawColumnCell事件里判断button控件是否点击了呢?请帮帮忙