ID NAME
1 A1
2 B1
3 A2
4 B2
. .
Combobox has binding information database name field:
For example:
A1
A2
B1
B2
C1
C2
Two problems:
1, when I enter A Combobox dropdown bindings A1, A2, is to use the input keywords fuzzy pull under the corresponding content, similar to Google search drop-down effect,
2, when I input is the ID is also can bind the corresponding NAME, such as type 3, automatic binding to A2
Thank you so much.
CodePudding user response:
These two problems is, in fact, you want to achieve in a combobox text box input characters automatically according to the character list in accordance with the input text name field is that so? This is not binding and binding name field should notProcedure Twordrun.com boboxChange (Sender: TObject);
Var I: nteger;
The begin
Combobox. The clear;
With adoquery1 do
The begin
The close;
SQL. The clear;
SQL. The add (' select the name from where a name like ' ' '+' % '+ combobox. Text +' % '+' ' 'or id=' "+ combobox. Text +" '");
The open;
end;
For I:=- to adoquery1. Do RecordCount - 1
The begin
Combobox. Items. The add (adoquery1. Fields. The Fields [0], Value);
Adoquery1. Next;
end;
Combobox. DroppedDown:=true;
Combobox. SetFocus;
end;
So should be able to, write directly, without verification