• 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;

  • 相关阅读:
    Zend Studio
    mysql workbench
    phpmyadmin
    navicat for mysql
    phpstorm
    django中 debug-toolbar插件 crm项目补充
    clean_data 和 instance的区别
    elasticsearch 第一章 初识elasticsearch
    爬虫第七章 scrapy中间件 + 基于crawlSpider全站爬取网络数据
    爬虫第六章 scrapy的具体应用 5大核心组件 scrapy持久化存储 请求传参
  • 原文地址:https://www.cnblogs.com/yoogoo/p/2457185.html
Copyright © 2020-2023  润新知