Home > Back-end >  How to implement dynamic fuzzy filter with the combobox and display the contents of the data table
How to implement dynamic fuzzy filter with the combobox and display the contents of the data table

Time:10-10

Hello, dragon island Lord! I was just playing with Delphi, have a question want to ask you, before I have seen your reply, when it comes to Delphi combobox automatically by filling a drop-down box of fuzzy query problems, you/Win32 ComboBoxEx was proposed for more convenient, I used after determine the convenience, but you can learn skills I not jing, screening process ComboBoxEx can only from the first letter or the first Chinese characters can be filtered, a CHANGE in Chinese characters not except 2, and I am in ComboBoxEx CHANGE writing code, the result is when the content of the input CHANGE and press down, have a lot of filtered data in ComboBoxEx drop-down list, why? Did you teach!

Procedure TForm1.Com boBoxEx1Change (Sender: TObject);
The begin
If (comboboxex1. Text<> ") then
The begin
With Query1 do
The begin
close;
SQL. The Clear;
SQL. The Add (' Select distinct name FROM student where names like: p ');
Params. ParamByName (" p "). The Value:='%' + trim (comboboxex1. Text) + '%';
The open;
end;
While not query1. Eof do
The begin
ComboBoxex1. Items. The add (query1. Fieldbyname (' name '). AsString) are identical.
Query1. Next;
end;
end;
end;

CodePudding user response:

And the like

CodePudding user response:

Empty the COMBOBOX, in front of the query to add

 procedure TForm1.Com boBoxEx1Change (Sender: TObject); 
The begin
If (comboboxex1. Text<> ") then
The begin
With Query1 do
The begin
close;
SQL. The Clear;
SQL. The Add (' Select distinct name FROM student where names like: p ');
Params. ParamByName (" p "). The Value:='%' + trim (comboboxex1. Text) + '%';
The open;
end;
While not query1. Eof do
The begin
Combobox1. Items. The Clear;
ComboBoxex1. Items. The add (query1. Fieldbyname (' name '). AsString) are identical.
Query1. Next;
end;
end;
end;

CodePudding user response:

Thank you for the original poster zhangzhen_927116 points, but still I tried I can't

CodePudding user response:

reference u012043438 reply: 3/f
thank you for the original poster zhangzhen_927116 point, but I tried or not

Remember next time reference, or others won't know you didn't reply,
You in describing the results you want, I see above the mentally
  • Related