NextGrid 没有添加行号的地方,也不像cxgrid可以在事件中画。
源码NxGridView单元中,procedure TNxListGridView6.PaintIndicators; 下面,可以直接画。
这是控件本身画indicator的地方:
StylePaint.PaintIndicator(IndicatorRect, ilRow, RowIndex = Control.SelectedLocation.Y,
Control.Selected[RowIndex]);
控件在indicator画三角的代码:NxGridStylePaint单元里
procedure TNxNativeGridPartStylePaint.PaintIndicator(IndicatorRect: TRect; Location: TNxIndicatorLocation; Selected,
Highlighted: Boolean);
if Selected then
with Canvas do
begin
Font.Color := clWindowText;
{ Actual or Styled Color? }
ArrowColor := GetHeaderTextColor([bsSelected]);
Pen.Color := ArrowColor;
Brush.Color := ArrowColor;
{ Center }
Pos := PosInRect(Succ(ArrowSize.cy), Succ(ArrowSize.cx), IndicatorRect, Classes.taRightjustify, taVerticalCenter);//这里我改为了RightJustify ,原本是Center。
{ Draw Arrow }
Polygon([
Point(Pos.X, Pos.Y),
Point(Pos.X + ArrowSize.cy, Pos.Y + ArrowSize.cy),
Point(Pos.X, Pos.Y + ArrowSize.cx)
]);
end;
直接在TNxListGridView6.PaintIndicators里面StylePaint.PaintIndicator下面添加:
StylePaint.Canvas.Brush.Color := clBtnFace;
StylePaint.Canvas.Font.Color := clWindowText;
p := PosInRect(0, 5, IndicatorRect, Classes.taLeftjustify, taVerticalCenter);
StylePaint.Canvas.TextOut(P.X,p.Y,(rowindex+1).ToString);
这里我是将上面画三角的地方改为了taRightJustify,这里设置为left。
整体只能说凑合用吧。