Friday, July 6, 2012

How to Add Value in The ComboBox From The Database at Runtime in Delphi Program?

If you want to add value to the Combo Box in Delphi then the point is you add some value in Combo Items ( see ComboBox properties in object inspector) If You using query to access the database you can write the code like this:



with Query1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from [table name]');
    Open;

         Query1.First; while (not Query1.Eof) do
              begin
                 ComboBox1.Items.Add(Query1.Fields[1].AsString);
                 Query1.Next;
              end;
    end;


 have a nice try :)

1 comment:

  1. i want to fill t combobox from database in LAZURAS using Mysql55comnnection and sql query.
    can u provide me code for it.

    ReplyDelete