孤独的猫

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

修改cxGrid的Indicator,让其显示当前记录的编号

在view的DrawIndicatorCell事件中写入“
var
  FValue:string;
  FBounds:TRect;
begin
  if Sender.OptionsView.Indicator then
  begin
   FBounds :=AViewInfo.Bounds;
   if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
   begin
    ACanvas.FillRect(FBounds);
    ACanvas.DrawComplexFrame(FBounds,clBtnHighlight,clBtnShadow,[bBottom,bLeft,bRight],1);
    FValue :=IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index+1); 
    InflateRect(FBounds,-3,-2);
    ACanvas.Font.Color :=clBlack;
    ACanvas.Brush.Style :=bsClear;
    ACanvas.DrawText(FValue,FBounds,cxAlignCenter or cxAlignTop);
    ADone :=True;
   end;
  end;  
end;

posted on 2011-09-25 22:28  孤独的猫  阅读(724)  评论(0)    收藏  举报