请问:在StringGrid内显示100行数据,窗口可见是10行,座边的FixedCols显示行号分别为
0,1,2,3,4,5,6,7,8,9 如果要拉动滚动条想看下面十一行以后的数据,FixedCols显示的行好
还是0,1,2,3,4,5,6,7,8,9 即使你把滚动条拉到末行,FixedCols显示的还是0,1,2,3,4,5,6,7,8,9
比如:
姓名 年龄 性别 工作单位
0 甲 33 男 xxxx
1 以 22 女 营业员
2 亿 29 女 四饿
3 乙 34 女 时光
4 丙 23 男 亿饿
5 ....................................
6 ....................................
7 ....................................
8 ....................................
9 ....................................
0,1,2,3,4,5,6,7,8,9 如果要拉动滚动条想看下面十一行以后的数据,FixedCols显示的行好
还是0,1,2,3,4,5,6,7,8,9 即使你把滚动条拉到末行,FixedCols显示的还是0,1,2,3,4,5,6,7,8,9
比如:
姓名 年龄 性别 工作单位
0 甲 33 男 xxxx
1 以 22 女 营业员
2 亿 29 女 四饿
3 乙 34 女 时光
4 丙 23 男 亿饿
5 ....................................
6 ....................................
7 ....................................
8 ....................................
9 ....................................
解决方案 »
- ClientDateSet复制另一个ClientDateSet数据
- missing SQl property什么问题啊
- 请教一个数据保存问题
- 请问怎样计算逆波兰公式?
- FASTREPORT的DEMO里能将报表打印成一行灰色底,一行白色底的样式,要设置那个属性呢?
- Delphi 文件处理问题
- delphi钩子函数该怎么写,一定要写在dll中吗
- *****如何将文本字符转换成程序代码*****
- 这个N为什么是4
- 是不是我太菜了,各位大虾帮帮我?一个INTERNET的“超级难题”???
- 用流来处理图象插入数据库遇到可凝的问题!!
- DELPHI中用ADO方式如何连接SQL MSDE版本啊 OLE 提供者是什么啊 跪拜求救啊!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;type
TForm1 = class(TForm)
sg: TStringGrid;
Button1: TButton;
procedure sgDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
State: TGridDrawState);
procedure sgTopLeftChanged(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
i:integer;
begin
if rect.Left=0 then
begin
i:=rect.Top div sg.DefaultRowHeight;
sg.Canvas.TextOut(0,rect.Top,inttostr(i));
sg.Update;
end;
end;
procedure TForm1.sgTopLeftChanged(Sender: TObject);
begin
sg.Repaint;
end;procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=1 to 100 do
sg.Cells[2,i]:=inttostr(i);
end;end.
请问这行i:=rect.Top div sg.DefaultRowHeight;
如何理解?
fixedcols的rect.Left=0,所以用
if rect.Left=0 then
而每一行的值i=单元格的top/每格的高度
所以
i:=rect.Top div sg.DefaultRowHeight;
(其中sg为stringgrid的name)
procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
i:integer;
begin
if (rect.Left=0) and (rect.Top>sg.DefaultRowHeight) then //这里,从第1行开始
begin
i:=rect.Top div sg.DefaultRowHeight-1; //i从0开始
sg.Canvas.TextOut(0,rect.Top,inttostr(i));
sg.Update;
end;
end;