• CXGRID 增加序号列


    private
    procedure SetRowNumber(var Sender: TcxGridTableView; var AViewInfo: TcxCustomGridIndicatorItemViewInfo; ACanvas: TcxCanvas; var ADone: boolean);
    procedure TfrmMain.SetRowNumber(var Sender: TcxGridTableView; var AViewInfo: TcxCustomGridIndicatorItemViewInfo; ACanvas: TcxCanvas; var ADone: boolean);
    var
      AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
      ATextRect: TRect;
      AFont: TFont;
      AFontTextColor, AColor: TColor;
    
      procedure DrawIndicatorImage(ACanvas: TcxCanvas; const R: TRect; AKind: TcxIndicatorKind);
      var
        X, Y: Integer;
      begin
        if AKind = ikNone then
          Exit;
        X := (R.Left + R.Right - cxLookAndFeelPainters.cxIndicatorImages.Width);
        Y := (R.Top + R.Bottom - cxLookAndFeelPainters.cxIndicatorImages.Height) div 2;
        cxLookAndFeelPainters.cxIndicatorImages.Draw(ACanvas.Canvas, X, Y, Ord(AKind) - 1);
      end;
    
    begin
      try
        AFont := ACanvas.Font;
        AColor := clBtnFace;
        AFontTextColor := clWindowText;
        if (AViewInfo is TcxGridIndicatorHeaderItemViewInfo) then
        begin
          ATextRect := AViewInfo.Bounds;
          InflateRect(ATextRect, -1, -1);
          Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.Bounds,
            ATextRect, [], cxBordersAll, cxbsNormal, taCenter, TcxAlignmentVert.vaCenter,
            False, False, '序号', AFont, AFontTextColor, AColor);
          ADone := True;
        end;
        if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
          Exit;
        ATextRect := AViewInfo.ContentBounds;
        AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
        InflateRect(ATextRect, -1, -1);
        if Sender.DataController.RecordCount > 0 then
        begin
          if AIndicatorViewInfo.GridRecord.Selected then
            AFontTextColor := clRed
          else
            AFontTextColor := clWindowText;
        end;
        Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
          ATextRect, [], [bBottom, bLeft, bRight], cxbsNormal, taCenter, TcxAlignmentVert.vaCenter,
          False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
          AFont, AFontTextColor, AColor);
        ADone := True;
      except
      end;
      DrawIndicatorImage(ACanvas, ATextRect, AIndicatorViewInfo.IndicatorKind);
    end;
    procedure TfrmMain.cxGridPlanBOMDBTableView1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    begin
      SetRowNumber(Sender, AViewInfo, ACanvas, ADone); //调用SetRowNumber函数,函数声明及实现见后
    end;

    效果图:

  • 相关阅读:
    越大优先级越高,优先级越高被OS选中的可能性就越大
    锁标记如果过多,就会出现线程等待其他线程释放锁标记
    使用带缓冲区的输入输出流的速度会大幅提高
    Bufferread有readline()使得字符输入更加方便
    java的开发主要以http为基础
    UDP也需要现有Server端,然后再有Client端
    端口是一种抽象的软件结构,与协议相关
    具有全球唯一性,相对于internet,IP为逻辑地址
    判断是否一个属性或对象可序列化
    把对象通过流序列化到某一个持久性介质称为对象的可持久化
  • 原文地址:https://www.cnblogs.com/redhat588/p/15830422.html
Copyright © 2020-2023  润新知