这是哪个控件呢?

程晨c 2012-02-23 12:01:54
大家看一下这个表格用的是哪个控件呢?
...全文
393 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
程晨c 2012-02-28
  • 打赏
  • 举报
回复
3.在Indicatoer列头显示"行号"两个字的方法如下

应修改为

3.在Indicatoer列头显示箭头的方法如下
程晨c 2012-02-28
  • 打赏
  • 举报
回复
感谢楼上各位朋友的关注。

现总结如下:

1.该控件使用的是cxgrid

2.在Indicatoer列显示每行序号的方法如下

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;


3.在Indicatoer列头显示"行号"两个字的方法如下
上述方法实现了indicator中显示行号,但是原来的选中时显示的小箭头因为绘制行号而消失了,所以需要加入以下语句


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;


4.在indicator列的列头显示“行号”字样的方法
这个需要修改cxGridTableView单元

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;


5.修改后的cxgrid样式如下


yygtpynn 2012-02-24
  • 打赏
  • 举报
回复
请问楼主如何在Indicator中显示行号?
程晨c 2012-02-24
  • 打赏
  • 举报
回复
谢谢case5166的关注

用Spy++跟踪了一下,下面的这个控件是用的Cxgrid




现在我已经实现了在cxgrid的Indicator中增加行号的功能了,但是不知道如何在显示行号的同时保留原来的三角形。
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
每2条,共3条----->毕竟左侧黄色区域不是做为显示行号的东东
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
这个问题确实难弄,即使是其它控件也比较难实现这种功能吧,CXGRID试试?
我的软件做法都是在最下面状态栏里显示行号的***

程晨c 2012-02-24
  • 打赏
  • 举报
回复
问题
1.(每列的TitleButton属性设置true后)单击任意一列的列头,“行号”两个字会消失。(每列的TitleButton属性设置true后)
2.当列较多时,拖动水平滚动条,隐藏第一列后,这种情况下,单击任意行,行号会消失,然后单击其他行后,上次单击的行的行号也不会显示。
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
只是用到了属性设置和画图,对数据操作是没有问题的,不知道你具体的问题是什么呢?消息中回复了你,但是没显示记录,不知道有否收到^呵呵
我看见佛 2012-02-24
  • 打赏
  • 举报
回复

if DataCol=0 then
begin

DBGridEh1.Canvas.Brush.Color:=clBtnFace;
DBGridEh1.Canvas.Font.Color:=clBlack;
DBGridEh1.Canvas.TextOut(0,0,'行号'); DBGridEh1TitleClick(DBGridEh1.Columns[0]);
DBGridEh1.Canvas.TextOut(Rect.Left-10,Rect.Top+3,IntToStr(DBGridEh1.DataSource.DataSet.RecNo));
end;

加上红色代码就可以了,,位置调整TextOut(0,0,'行号');两个00的值
onlyou13 2012-02-24
  • 打赏
  • 举报
回复
用spy++看下程序就知道
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
颜色你自己调了
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
第二个是设置DBGRIDEH的OPTIONS属性dgalwayshowEditor=true就可以了
要改这个颜色,还还得加上这个代码了,高亮的颜色没有相应属性设置,也得改源代码吧
procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin

with TStringGrid(DBGrideh1) do begin
if row = MouseCoord(Rect.Left+1, Rect.Top+1).Y then
begin
Canvas.Brush.Color := clMenuHighlight;
Canvas.Font.Color := clWhite;
end;
end;
end;

第一个,等下再试
我看见佛 2012-02-24
  • 打赏
  • 举报
回复
抱歉,手头上暂时没有装CXGRID,,,
lzg827 2012-02-23
  • 打赏
  • 举报
回复
貌似是DBGrid。
不过要实现复杂功能,用cxGrid会简单点。
程晨c 2012-02-23
  • 打赏
  • 举报
回复
现在使用DBGridEh实现上图效果时遇到的问题主要是两个
1.是如何增加“行号”两个字。
2.是如何实现,单击(只需单击一次,而不是先单击使其获得焦点然后再次单击一次)某个单元格时,a.单元格所在的行整行为深蓝色选中状态,b.选中的单元格背景色为白色。(如上图所示)
如果将RowSelect属性设置为True的话,可以选择整行,但是Edit属性会自动变为False,即不能编辑单元格。

目前剩余20分了,等其他帖子结贴返还分数后,再给大家补上!
程晨c 2012-02-23
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 kaikai_kk 的回复:]
dbgrideh
[/Quote]

如何增加“行号”这两个字呢?
程晨c 2012-02-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 case5166 的回复:]
刚刚那帖子的功能和这个应该也差不多了吧,cxgrid,wwdbgrid,dbgrideh应该都是可以的,这三个是我用过功能比较完善的,但是完全一样不容易
[/Quote]

感谢case5166的关注!
我看见佛 2012-02-23
  • 打赏
  • 举报
回复
刚刚那帖子的功能和这个应该也差不多了吧,cxgrid,wwdbgrid,dbgrideh应该都是可以的,这三个是我用过功能比较完善的,但是完全一样不容易
kaikai_kk 2012-02-23
  • 打赏
  • 举报
回复
dbgrideh
jfhyn 2012-02-23
  • 打赏
  • 举报
回复
DBGRIDEH 或者CXGRID都可以实现
加载更多回复(3)

5,378

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧