Home > Back-end >  For Delphi landing window, with the combobox display in the database user name
For Delphi landing window, with the combobox display in the database user name

Time:10-04

In the login window, combobox display user name in the database, and use the following sentence:
Procedure TLogin.Com boBox1DropDown (Sender: TObject);
Var
I: integer;
The begin
Adoquery1. Close;
Adoquery1. SQL. The Clear;
Adoquery1. SQL. The Add (' select name from user list);
Adoquery1. Open;
While not adoquery1. Eof do
The begin
Combobox1. Items. The Add (adoquery1 fieldbyname (' name '). AsString) are identical.
Adoquery1. Next;
end;
end;
The question now is in the database only sys a user, but a combobox per click will increase the sys user options,

CodePudding user response:

Add combobox1. Items. The Clear;
 
Procedure TLogin.Com boBox1DropDown (Sender: TObject);
Var
I: integer;
The begin
Combobox1. Items. The Clear;
Adoquery1. Close;
Adoquery1. SQL. The Clear;
Adoquery1. SQL. The Add (' select name from user list);
Adoquery1. Open;
While not adoquery1. Eof do
The begin
Combobox1. Items. The Add (adoquery1 fieldbyname (' name '). AsString) are identical.
Adoquery1. Next;
end;
end;

CodePudding user response:

Drop down box upstairs to the user name can also be placed in the DropDown can not events

CodePudding user response:

This is a question of code is repeated many times,
Suggestions in the From. OnCreat event, to join the above code, the code executed only once,

CodePudding user response:

Personally, I suggest don't under the DropDown can events, such as really need to. Please add combobox1 Items. The Clear;

CodePudding user response:

reference 1st floor sedshy response:
add combobox1. Items. The Clear;
 
Procedure TLogin.Com boBox1DropDown (Sender: TObject);
Var
I: integer;
The begin
Combobox1. Items. The Clear;
Adoquery1. Close;
Adoquery1. SQL. The Clear;
Adoquery1. SQL. The Add (' select name from user list);
Adoquery1. Open;
While not adoquery1. Eof do
The begin
Combobox1. Items. The Add (adoquery1 fieldbyname (' name '). AsString) are identical.
Adoquery1. Next;
end;
end;


Positive solution!

CodePudding user response:

Initialize the user needs to be loaded only once, on OnShow or OnCreate is ok,

CodePudding user response:

In OnShow combobox1. Items. The Clear or OnCreate load
  • Related