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;
时间: 2024-10-05 19:37:09