注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Martian 's Blog

Welcome Martian 's Blog!

 
 
 

日志

 
 
 
 

cxgrid动态显示行号  

2012-08-07 10:51:48|  分类: delphi |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

uses cxLookAndFeelPainters;

type

TMyCxGrid = class(TObject)
class procedure DrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
end;

{ TMyCxGrid }

class procedure TMyCxGrid.DrawIndicatorCell(Sender: TcxGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
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);

Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.Bounds,
ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter,
False, False, 'NO',AFont, AFontTextColor, AColor);
ADone := True;
end;
if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
Exit;
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
InflateRect(ATextRect, -1, -1);

if AIndicatorViewInfo.GridRecord.Selected then
AFont.Style := ACanvas.Font.Style + [fsBold]
else
AFont.Style := ACanvas.Font.Style - [fsBold];

Sender.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;

procedure ShowLineNo(c: TcxGridDBTableView);
begin
c.OptionsView.Indicator := True;
c.OptionsView.IndicatorWidth := 40;
c.OnCustomDrawIndicatorCell := TMyCxGrid.DrawIndicatorCell;
end;

  评论这张
 
阅读(873)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018