Home > Back-end >  In the second time I show how empty before combobox content
In the second time I show how empty before combobox content

Time:09-22

Before I click bottom2 but combobox content remains inside, so every click content will accumulate a, how content before clicking the combobox when empty? Thank you

Procedure TForm1. Button2Click (Sender: TObject);

Var
I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct code from alldata where type='" + ComboBox2. Text + "' ");
The Open;
end;
For I:=0 to ADOQuery1. Do RecordCount - 1
The begin
ComboBox1. Items. The Add (ADOQuery1 fieldbyname (' code '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox1. ItemIndex:=0;
end;

CodePudding user response:

ComboBox1. Items. The clear;

CodePudding user response:


A, a list of empty ComboBox
ComboBox1. Items. The clear;

Second, the list of the ComboBox, add characters
ComboBox1. Items. The Add (' characters');

Three, the choice of the empty ComboBox characters
ComboBox1. Text:=' ';

 
Procedure TForm1. Button2Click (Sender: TObject);
Var I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct code from alldata where type='" + ComboBox2. Text + "' ");
ComboBox2. Text:=' ';
The Open;
end;
ComboBox1. Items. The clear;
For I:=0 to ADOQuery1. Do RecordCount - 1
The begin
ComboBox1. Items. The Add (ADOQuery1 fieldbyname (' code '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox1. ItemIndex:=0;
end;

CodePudding user response:

refer to the second floor lyhoo163 response:
a, empty ComboBox list
ComboBox1. Items. The clear;

Second, the list of the ComboBox, add characters
ComboBox1. Items. The Add (' characters');

Three, the choice of the empty ComboBox characters
ComboBox1. Text:=' ';

 
Procedure TForm1. Button2Click (Sender: TObject);
Var I: integer;
The begin
With ADOQuery1 do
The begin
The Close;
SQL. The Clear;
SQL. The Add (' select distinct code from alldata where type='" + ComboBox2. Text + "' ");
ComboBox2. Text:=' ';
The Open;
end;
ComboBox1. Items. The clear;
For I:=0 to ADOQuery1. Do RecordCount - 1
The begin
ComboBox1. Items. The Add (ADOQuery1 fieldbyname (' code '). AsString) are identical.
ADOQuery1. Next;
end;
ComboBox1. ItemIndex:=0;
end;



First remove, add. Should be like this

CodePudding user response:

Combobox1. The clear;

CodePudding user response:

1st floor is positive solutions
  • Related