• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Basic question...

I have a simple query like this

Select * from <Table>

when I put a DataSource and a DBCombo, the DBCombo not show the data. The Combo only show the first record of dataset.

Any idea?

Thanks, Marcelo
0
Marcelito
Asked:
Marcelito
1 Solution
 
aubsCommented:
The idea of the DBCombobox is that you fill the items list yourself to allow the user to select an appropriate one for the field.

If you are expecting to see all the records of a particular field in a combo box use the DBLookupComboBox

Aubs
0
 
hobbit123Commented:
I don't understand. You want do use a TDBComboBox component with TDataSource? You need to set DataSource and DataField properties and everything should be fine. If you want to see a next record, you should call <YourDataSetName>.Next;
 
                   Hobbit123

0
 
JoeBoothCommented:
Use a DBLOOKUPCOMBO instead of a DBCOMBO and set the ListSource and ListField properties to the datasource and field name.

DBCOMBO expects you to fill the list box and controls what gets entered into the field.

DBLOOKUPCOMBO fills the list box with items from the dataset specified in the Listsource
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ITugayCommented:
Of course, you will see nothing, if you place nothing in TDBComboBox.Items.
You can fill it at design time by enter desired values manually, or in runtime.
In runtime you may do it like this:

in designmode define OnDropDown event.

procedure TForm1.DBCombobox1.DropDown(Sender: TObject);
begin
   DBCombobox1.Items.Clear;
   DBCombobox1.Items.Add('000');
   DBCombobox1.Items.Add('001');
   DBCombobox1.Items.Add('02');
   DBCombobox1.Items.Add('text');
// you may fill list by values from anoter table
end;

Cheers,

Igor.
0
 
GoodTimesCommented:
DBComboBox is intended to allow the user to pick a value for a specific field. It is not intended to select a record in the database.
If you want to fill the DBComboBox with data from the table do the following:

with Table do
begin
   First;
   while not EOF do
   begin
      DBCombo.Items.Add(FieldByName('ComboField').AsString);
      Next;
   end;
end;

This should add the values in the table to the dbcombobox.
put in FieldByName the name of the field which the dbcombobox is supposed to represent.

I hope this explains things a bit..
Omri
0
 
FreakyCommented:

The only data-sensitive thing in a DBComboBox is the editfield.
The dropdown-list does not contain the records from your query.

Try to insert the datarows like "GoodTimes" explained above, but set a "DBComboBox.Items.Clear" just behind the "Table.First" or your list will be quite full after some expandings .. ;)

 Greets

  Sascha

PS: Sorry for my bad English - German is easier, I think .. ;)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now