分享

dbgrid显示序号

 独孤求财 2012-03-20

dbgrid显示序号

时间:2011-5-26来源:yang 作者: peng点击: 26次

 修改GRID.pas
在TCustomGrid.SetColWidths事件改为:
procedure TCustomGrid.SetColWidths(Index: Longint; Value: Integer);
begin
  if FColWidths = nil then
    UpdateExtents(FColWidths, ColCount, DefaultColWidth);
  if Index >= ColCount then InvalidOp(SIndexOutOfRange);
  if Value <> PIntArray(FColWidths)^[Index + 1] then
  begin
  if Value < 12 then Value := 30;   //新增
    ResizeCol(Index, PIntArray(FColWidths)^[Index + 1], Value);
    PIntArray(FColWidths)^[Index + 1] := Value;
    ColWidthsChanged;
  end;
end;

修改DBGRID.pas
在procedure TCustomDBGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);事件加
找到下面这一行
        FIndicators.Draw(Canvas, ALeft,
          (ARect.Top + ARect.Bottom - FIndicators.Height) shr 1, Indicator, True);
        if ACol <0 then
        begin
          Canvas.TextRect(ARect,0,(ARect.Top + ARect.Bottom - FIndicators.Height) shr 1
          ,inttostr(self.DataSource.DataSet.RecNo));
        end; //新增  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多