to xinphoebe:
不要用INC函数,用timer的inteval不就行了吗,看来只好贴出程序了。
//================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Table1: TTable;
Table2: TTable;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
Table3: TTable;
Timer2: TTimer;
Timer3: TTimer;
Timer4: TTimer;//为控制3个dbgrid按时显示的计时器
DataSource2: TDataSource;
DataSource3: TDataSource;
Button1: TButton;//用于使timer4开始工作
procedure Timer4Timer(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag:integer=1;
implementation
{$R *.dfm}
procedure TForm1.Timer4Timer(Sender: TObject);
begin
case flag of
1:begin
flag:=2;
dbgrid1.Visible:=true;
timer1.Enabled:=true;
dbgrid2.Visible:=false;
dbgrid3.Visible:=false;
timer2.Enabled:=false;
timer3.Enabled:=false;
end;
2:begin
flag:=3;
dbgrid2.Visible:=true;
timer2.Enabled:=true;
dbgrid1.Visible:=false;
dbgrid3.Visible:=false;
timer1.Enabled:=false;
timer3.Enabled:=false;
end;
3:begin
flag:=1;
dbgrid3.Visible:=true;
timer3.Enabled:=true;
dbgrid1.Visible:=false;
dbgrid2.Visible:=false;
timer1.Enabled:=false;
timer2.Enabled:=false;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if table1.Eof then
table1.First
else
table1.Next
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
timer4.Enabled:=true;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
if table2.Eof then
table2.First
else
table2.Next
end;
procedure TForm1.Timer3Timer(Sender: TObject);
begin
if table3.Eof then
table3.First
else
table3.Next
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.Interval:=1000;//1000为1秒
timer2.Interval:=1000;
timer3.Interval:=1000;
timer4.Interval:=5000;
timer1.Enabled:=false;//让timer停止计时
timer2.Enabled:=false;
timer3.Enabled:=false;
timer4.Enabled:=false;
end;
end.
//================