您的位置:首页 > 其它

timer实现Grid自动换行(连续相同的id跳到下一行)

2015-11-06 15:23 344 查看
private
{ Private declarations }
FRow: Integer;
procedure SetRow(const Value: Integer);

public
{ Public declarations }
property Row : Integer read FRow write SetRow default -1;  // 属性
end;

implementation

{$R *.fmx}

{ Tfrm }

procedure Tfrm.SetRow(const Value: Integer);
begin
if(Value<>FRow) then begin
FRow:=Value;
G1.SelectRow(Value);
Timer1.Interval:=G1.Cells[3,Value].ToInteger();
end;
end;

procedure Tfrm.Timer1Timer(Sender: TObject);
var
n, i, j: Integer;
begin
n := FRow + 1;  // 当前行位置
j := 0;         // IP相同的个数
if n < G1.RowCount - 1 then // 防止超界
begin
for i := 0 to G1.RowCount - 1 do
begin
if i + 1 < G1.RowCount - 1 then
if (G1.Cells[0, FRow] = G1.Cells[0, FRow + i]) then // 判断相邻行IP的相同个数  若相同则相加否则退出循环
Inc(j)
else break;
end;
if j <> 0 then n := FRow + j;
end;
if (n >= G1.RowCount - 1) then
n := 0;
Row := n;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: