5,378
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
X, Y: Integer;
begin
if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then Exit;
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
InflateRect(ATextRect, -2, -1);
if AIndicatorViewInfo.GridRecord.Selected then //如果是选中的行号则Indicatoer字体加粗
begin
ACanvas.Font.Style := Canvas.Font.Style + [fsBold];
end
else
begin
ACanvas.Font.Style := Canvas.Font.Style - [fsBold];
end;
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter,
False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
ACanvas.Font,ACanvas.font.Color,ACanvas.Brush.color );
ADone := True;
end;
procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
//......此处为显示行号的语句
ADone := True;
if AIndicatorViewInfo.GridRecord.Selected then//如果当前为选中行,则显示箭头
begin
with cxIndicatorImages, ATextRect do
begin
X := Right - Width;
Y := (Top + Bottom - Height) div 2 ;
end;
cxIndicatorImages.Draw(ACanvas.Canvas, X, Y, Ord(ikArrow) - 1);
end;
end;
procedure TcxGridIndicatorHeaderItemPainter.DrawContent;
begin
with ViewInfo do
begin
LookAndFeelPainter.DrawHeader(Self.Canvas, Bounds, Bounds, [nRight],cxBordersAll,
GridCellStateToButtonState(State), taLeftJustify, vaTop, False,
False, '', nil, clNone, Params.Color, DrawBackgroundHandler);
if GridView.GetOptionsView.Indicator then //如果为indicator则增加“行号”字样
LookAndFeelPainter.DrawHeader(Self.Canvas,Bounds,Bounds,[],cxBordersAll,
cxbsNormal, taCenter, vaCenter,
False, False, '行号',
Self.Canvas.Font,Self.Canvas.font.Color,Self.Canvas.Brush.color);
if State = gcsPressed then
LookAndFeelPainter.DrawHeaderPressed(Self.Canvas, Bounds);
end;
end;