Delphi cxGrid加行号
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, -, -); 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, -, -);
ASender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
ATextRect, [], [bBottom, bLeft, bRight], cxbsNormal, taCenter, vaCenter,
False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + ),
AFont, AFontTextColor, AColor);
ADone := True;
ASender.LookAndFeelPainter.DrawIndicatorImage(ACanvas, ATextRect, AIndicatorViewInfo.IndicatorKind);
end;
如果你不要行标志的话,你可以不改控件
直接注释掉这一行: ASender.LookAndFeelPainter.DrawIndicatorImage(ACanvas, ATextRect, AIndicatorViewInfo.IndicatorKind);
要标志的话,在DrawIndicatorImage 从这里跟进去(Ctrl+左键单击)
在 cxLookAndFeelPainters 单元中作如下修改:
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 ; //居中
end;
cxIndicatorImages.Draw(ACanvas.Canvas, X, Y, Ord(AKind) - );
end;
注意,我已注明靠右的那一行, 就是去掉 DIV 2 了,
还要改一个地方:
SKIN控件目录下的dxSkinLookAndFeelPainter单元,找到
TdxSkinLookAndFeelPainter.DrawIndicatorImage 函数
的
OffsetRect(ARect, (Left + Right - cx div 2) , (Top + Bottom - cy) div 2);
这一行,将 (Left + Right - cx div 2) 改为(Left + Right - cx) 也是去掉 div 2 就是靠右;
修改后: OffsetRect(ARect, (Left + Right - cx) , (Top + Bottom - cy) div 2);
使用
procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
begin
SetRowNumber(Sender,AviewInfo,ACanvas,ADone);
end;
另外序号列的列宽最好改为35!
效果图:
Delphi cxGrid加行号的更多相关文章
- vim 加行号 和取消行号
:set nu #是加行号 :set nonu #是去掉行号
- delphi cxgrid 使用方法
delphi cxgrid 使用方法1.绑定数据 方法 cxGrid1DBTableView1.DataController.DataSource:=DataSource12.去掉"Drag ...
- jquery plugins —— datatables 增加行号
table = $("#Table").DataTable({ "rowCallback": function (row, data, dataIndex) { ...
- vi命令加行号查找替换等命令
一.加行号 : set nu二.vi查找: 当你用vi打开一个文件后,因为文件太长,如何才能找到你所要查找的关键字呢?在vi里可没有菜单-〉查找, ...
- 关于Delphi cxGrid主从表中从表只能编辑第一条记录的问题
在Delphi cxGrid主从表中从表只能编辑第一条记录,这个问题是由于设置主从关联字段错误造成的. 从表DBtableView2的keyfieldnames,DetailKeyFieldNames ...
- 怎么在SQL查询的结果里加行号?
怎么在SQL查询的结果里加行号? 学习了:https://zhidao.baidu.com/question/91188037.html mysql : ) as rowNo From a, () ) ...
- 用UNIX的cat命令用于给文本加行号 (转载)
转载:http://blog.csdn.net/vicant/article/details/2317721 有时候需要给文本加上行号,用UNIX的cat命令可以进行这项工作. cat命令的用法如下: ...
- C# datagridview、datagrid、GridControl增加行号
01 - WinForm中datagridview增加行号 在界面上拖一个控件dataGridView1,在datagridview添加行事件中添加如下代码: private void dataGri ...
- Delphi CxGrid 汇总(4)
1. CxGrid汇总功能 ① OptionsView-Footer设置为True,显示页脚 ② CxGrid的Summary选项卡定义要汇总的列和字段名及汇总方式,Footer选项卡定义 ...
随机推荐
- 使用Tensoflow实现梯度下降算法的一次线性拟合
# Author Qian Chenglong import tensorflow as tf import numpy as np #生成100个随机数据点 x_date=np.random.ran ...
- APR Recipe
1, pt fix 后生成的 icctcl,回到 icc source 后,如果需要eco_route,建议先关掉 timing_driven,因为 icc 与 pt 看到的 timing 情况一般 ...
- JAVA框架 SpringMVC RequestMapping讲解
一.窄化请求映射 在class上做RequestMapping注解. 好处:避免在同一个项目中和其他人的url重复,出现请求混乱问题,便于管理. @Controller @RequestMapping ...
- ansible 变量定义和引用
cat /etc/ansible/hosts [nodes]10.2.1.232 key=23210.2.1.43 key=43 cat debug.yaml ---- name: test how ...
- WPF EventTrigger,BeginStoryboard
<Window x:Class="WpfApplication2.LoginWind" xmlns="http://schemas.microsoft.com/wi ...
- 20155217《网络对抗》Exp09 Web安全基础实践
20155217<网络对抗>Exp09 Web安全基础实践 实践内容 关于webgoat:询问了很多人在安装webgoat时出现了错误,安装失败,因此直接通过同学copy了老师的虚拟机进行 ...
- 20155305《网络对抗》Web安全基础实践
20155305<网络对抗>Web安全基础实践 基础问题回答 SQL注入攻击原理,如何防御? 原理:SQL注入攻击指的是通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL ...
- 20155318 Exp1 PC平台逆向破解(5)M
20155318 Exp1 PC平台逆向破解(5)M 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入 ...
- WPF自定义控件的自定义属性绑定后不更新问题
原文:WPF自定义控件的自定义属性绑定后不更新问题 需要在绑定时设置属性变更触发 UpdateSourceTrigger=PropertyChanged 例如: <Border CornerRa ...
- 阿里云OSS不同账号之间的迁移
目录 一.需求说明 二.Ossimport概述 三.配置运行环境 1.配置jdk环境 2.部署方式 3.下载并部署ossimport 四.修改单机Job的配置文件local_job.cfg 五.执行迁 ...