zoukankan      html  css  js  c++  java
  • DBGrid 单双行显示不同颜色

    procedure TfrmMain.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    var
      aIndex:Integer;
      aDBGrid:TDBGrid;
    begin
      if Sender is TDBGrid then
      begin
        aDBGrid:=TDBGrid(Sender);
        if State=[] then
        with aDBGrid do
        begin
          if Assigned(DataSource) and Assigned(DataSource.DataSet)
            and DataSource.DataSet.Active
            and not(SelectedRows.Find(DataSource.DataSet.Bookmark,aIndex)) then
          begin
            //aIndex:=(Rect.top div 17);//DataSource.DataSet.RecNo;
            try
              aIndex:=DataSource.DataSet.RecNo;
            Except
            end; 
            if odd(aIndex) then
              aDBGrid.Canvas.Brush.Color:=clWindow //白色
            else
              aDBGrid.Canvas.Brush.Color:=clBtnFace;//灰色
            aDBGrid.Canvas.Font.Color := clWindowText;
            TDBgrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
          end;
        end
        else
        if ( Sender <> Screen.ActiveControl ) then
        with aDBGrid.Canvas Do
        begin
          Brush.Color := clBtnFace;
          Font.Color := clWindowText;
          TDBgrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
        end;
      end;
    end;

  • 相关阅读:
    CSS3——过渡
    CSS——优雅降级和渐进增强
    jq1 颜色填充器 和清空指定颜色
    1. 初识node
    javaSE- 01
    鼠标悬浮图片时弹出透明提示图层的jQuery特效
    通过jQuery制作电子时钟表的代码
    9种网页Flash焦点图和jQuery焦点图幻灯片
    7种网页图片切换方式代码
    21种网页在线客服代码实例演示
  • 原文地址:https://www.cnblogs.com/yoogoo/p/2457185.html
Copyright © 2011-2022 走看看