大家看一下这个表格用的是哪个控件呢?
解决方案 »
- 讨论一下笔记本价格(没有贴错地方),随便放点分
- listview 如何才能编辑其内容?
- 本地与远程数据库间如何更新、增加、删除....数据表内容?
- 哎~~~三叔六婶……刚出炉的大问题,不买也来看看啊!!!!
- 我现在不知道该怎么办,大家帮我出出主意!
- 有关在IE里自动安装的问题----有类似问题或超级大吓请看
- 急急|||谁有delphi常规控件详解之类的文档或者电子书籍啊,高分相赠
- 弱智问题,Tcombobox如何取得当前选中的text?
- 我发过一次,可没有人回答,控制机群的问题?
- ADO多表连接操作中可不可以限制只对一张表或某几张表操作?急,在线等候!多谢!
- 如何隐藏cmbobox的边框,并为其增加下划线
- 自定义类封装中 自定义数据类型要封装到单独一个pas吗?
不过要实现复杂功能,用cxGrid会简单点。
1.是如何增加“行号”两个字。
2.是如何实现,单击(只需单击一次,而不是先单击使其获得焦点然后再次单击一次)某个单元格时,a.单元格所在的行整行为深蓝色选中状态,b.选中的单元格背景色为白色。(如上图所示)
如果将RowSelect属性设置为True的话,可以选择整行,但是Edit属性会自动变为False,即不能编辑单元格。目前剩余20分了,等其他帖子结贴返还分数后,再给大家补上!
要改这个颜色,还还得加上这个代码了,高亮的颜色没有相应属性设置,也得改源代码吧
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;第一个,等下再试
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的值
1.(每列的TitleButton属性设置true后)单击任意一列的列头,“行号”两个字会消失。(每列的TitleButton属性设置true后)
2.当列较多时,拖动水平滚动条,隐藏第一列后,这种情况下,单击任意行,行号会消失,然后单击其他行后,上次单击的行的行号也不会显示。
我的软件做法都是在最下面状态栏里显示行号的***
现在我已经实现了在cxgrid的Indicator中增加行号的功能了,但是不知道如何在显示行号的同时保留原来的三角形。
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样式如下