在cxGrid的GridView属性设置事件onGridCustomDrawIndicatorCell,事件关键代码如下:
procedure TfrmHidden_Trouble.GridCustomDrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
aCV:TcxCanvas;
begin
inherited;
//======引用单元 cxLookAndFeelPainters
if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
Exit;
aCV:=ACanvas ;
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
InflateRect(ATextRect, -2, -1);
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
ATextRect, [], cxBordersAll, cxbsNormal, taCenter, TcxAlignmentVert(vaCenter),
False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
acv.Font,acv.font.Color,acv.Brush.color );
ADone := True;
end;
本文介绍如何在cxGrid中通过设置GridView属性并使用onGridCustomDrawIndicatorCell事件来自定义行号的显示样式。通过具体示例代码展示了如何利用cxLookAndFeelPainters进行单元格的绘制。
1864

被折叠的 条评论
为什么被折叠?



