在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
procedure SetRowNumber(var ASender: TcxGridTableView; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ACanvas: TcxCanvas; var ADone: boolean); uses cxLookAndFeelPainters; procedure SetRowNumber(var ASender: TcxGridTableView; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ACanvas: TcxCanvas; var ADone: boolean); var AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo; ATextRect: TRect; AFont: TFont; AFontTextColor, AColor: TColor; begin AFont := ACanvas.Font; AColor := clBtnFace; AFontTextColor := clWindowText ; if (AViewInfo is TcxGridIndicatorHeaderItemViewInfo) then begin ATextRect := AViewInfo.Bounds; InflateRect(ATextRect, -1, -1); ASender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.Bounds, ATextRect, [], cxBordersAll, cxbsNormal, taCenter, 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); ASender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds, ATextRect, [], [bBottom, bLeft, bRight], cxbsNormal, taCenter, vaCenter, False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1), AFont, AFontTextColor, AColor); ADone := True; ASender.LookAndFeelPainter.DrawIndicatorImage(ACanvas, ATextRect, AIndicatorViewInfo.IndicatorKind); end; 如果你不要行标志的话,你可以不改控件 class procedure TcxCustomLookAndFeelPainter.DrawIndicatorImage(ACanvas: TcxCanvas; const R: TRect; AKind: TcxIndicatorKind); var X, Y: Integer; begin if AKind = ikNone then Exit; with cxIndicatorImages, R do begin X := (Left + Right - Width); //靠右 Y := (Top + Bottom - Height) div 2; //居中 end; cxIndicatorImages.Draw(ACanvas.Canvas, X, Y, Ord(AKind) - 1); end; 注意,我已注明靠右的那一行, 就是去掉 DIV 2 了, 1 procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell( 2 Sender: TcxGridTableView; ACanvas: TcxCanvas; 3 AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean); 4 begin 5 SetRowNumber(Sender,AviewInfo,ACanvas,ADone); 6 end; 另外序号列的列宽最好改为35!
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论