The unit;
Interface
USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Vcl. StdCtrls, Vcl. ExtCtrls, Vcl.Com Ctrls,
Data. The DB Data. Win. The ADODB library;
Type
TForm1=class (TForm)
ListView1: TListView;
Label1: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
Panel1: TPanel;
CheckBox5: TCheckBox;
For: TButton;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Button4: TButton;
Label2: TLabel;
Timer1: TTimer;
Procedure Button1Click (Sender: TObject);
Procedure Memo1Change (Sender: TObject);
Procedure Button3Click (Sender: TObject);
Procedure Button4Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Form1: TForm1;
Implementation
{$R *. DFM}
Procedure TForm1. Button1Click (Sender: TObject);
Var
I: integer;
TempColumn: TListColumn;
TempItem: TListItem;
The begin
The begin
Timer1. Enabled:=false;
With adoquery1 do
The begin
The close;
ADOConnection1:=TADOConnection. Create (nil);
Adoconnection1. LoginPrompt:=false;
ADOConnection1. The ConnectionString:='. The Provider=Microsoft Jet. The OLEDB. 4.0; The Data Source=Data. MDB; Persist Security Info=False ';
Adoquery1. Connection:=ADOConnection1;
SQL. The Clear;
SQL. The add (' select * from want want # ');
The Open;
end;
For I:=0 to adoquery1. Do FieldCount - 1
The begin
TempColumn:=self ListView1. Columns. The Add;
TempColumn. Caption:=adoquery1. Fields [I] FieldName.
end;
Adoquery1. First;
While not adoquery1. Eof do
The begin
TempItem:=self ListView1. Items. The Add;
TempItem. Caption:=adoquery1. Fields [0]. AsString;
For I:=1 to adoquery1. Do FieldCount - 1
The begin
TempItem. SubItems. Add (adoquery1 Fields [I] AsString) are identical.
end;
Adoquery1. Next;
end;
Timer1. Enabled:=false;
end;
end;
//is displayed in the listview1
Procedure TForm1. Button3Click (Sender: TObject);//save
Var
Mylist: TstringList;
N, I: integer;
STR, tem: string;
The begin
If listview1. Items. Count> 0 then
The begin
Try
Mylist:=TStringlist. Create;
For n:=0 to listview1. Items. Do the begin the Count - 1
STR:=';
For I:=0 to listview1. Items. The Item [n]. SubItems. Do the Count - 1
The begin
Tem:=listview1. Items. The Item [n]. SubItems. Strings [I];
If (tem=' ') then tem:='# # # #';
If (STR=' ') then the STR:=tem
The else STR:='+' STR + + tem;
end;
Mylist. Add (STR);
end;
Showmessage (mylist. Text);
Mylist. SaveToFile (' d: \ 123. TXT);
The finally
Mylist. Free;
end;
End
The else begin
Application. The MessageBox (' no data can be exported! ', 'prompt', MB_OK + MB_Iconinformation);
end;
end;
Procedure TForm1. Button4Click (Sender: TObject);
The begin
Listview1. Items. The Clear;
end;
Procedure TForm1. Memo1Change (Sender: TObject);//button in the true and false
The begin
If not (memo1. Lines. The Text=' ') then
The begin
For the Enabled:=true;
End
The else
The begin
For the Enabled:=false;
end;
end;
end.
CodePudding user response:
Timer1 handle events didn't write you ah, you do not use the Timer1,
Procedure TForm1. Button1Click (Sender: TObject);
Var
I: integer;
TempColumn: TListColumn;
TempItem: TListItem;
The begin
The begin
Timer1. Enabled:=false;
With adoquery1 do
The begin
The close;
ADOConnection1:=TADOConnection. Create (nil);
Adoconnection1. LoginPrompt:=false;
ADOConnection1. The ConnectionString:='. The Provider=Microsoft Jet. The OLEDB. 4.0; The Data Source=Data. MDB; Persist Security Info=False ';
Adoquery1. Connection:=ADOConnection1;
SQL. The Clear;
SQL. The add (' select * from want want # ');
The Open;
end;
For I:=0 to adoquery1. Do FieldCount - 1
The begin
TempColumn:=self ListView1. Columns. The Add;
TempColumn. Caption:=adoquery1. Fields [I] FieldName.
end;
Adoquery1. First;//data ready, to the first record, the above code is your own
Timer1. Interval:=1000;//perform regularly, once per second,
Timer1. Enabled:=true;//start the timer
end;
end;
//timing of the event to write the code
Procedure TFormMain. Timer1Timer (Sender: TObject);
The begin
//if not to the database, will add a
If not adoquery1. Eof then
The begin
TempItem:=self ListView1. Items. The Add;
TempItem. Caption:=adoquery1. Fields [0]. AsString;
For I:=1 to adoquery1. Do FieldCount - 1
The begin
TempItem. SubItems. Add (adoquery1 Fields [I] AsString) are identical.
end;
nullnullnullnullnullnullnull