TDBComboBox shouldn't it be able to populate itself?

I've been futzing with the TDBComboBox and the best I can to is one element from the database automatically.  I have set up the data source and data field correctly and played with the cache a bit but still just one element.  I need to get the entire field set into it to give the user to select from a series of registers.  Other examples on the net show how to manually add the elements to the database.  But that is just a TComboBox.  I have been playing with the properties and have failed miserably to this point.

This doesn't seem to be a difficult problem but I need some special Ed quickly.  One of you guys or gals know what I am missing to make this simple.  As with all other software process I don't have the time to investigate new tools..  yet again folks thanks ahead of time.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

graberAuthor Commented:
Just checked the borland sight and this is exactly the case.  Can any one fill in the gaps as to why?
The 'DB' aspect of the TDBCombo is just that,  it only edits the field you point it to.  So the dropdown is not connected in any way to the actual database.  

To get that kind of functionality you need to use the DBLookupComboBox which has the Datafield AND the ListFields.  Data field source is what you are editing and the list field source is what shows in the drop down.

graberAuthor Commented:
thanks kode I'll give it a try.
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

George TokasCommented:
>>I need to get the entire field set into it to give the user to select from a series of registers.
Is this some kind of MPU like Atmel,Microchip??
If yes what is the functionality?
Maybe there is another way through.

graberAuthor Commented:
Hey George!  While the software is hosted on a PowerPc the registers in question on not.  Communication takes place over a VME or PCI buss....  What do you have up your sleeve?

Kode-> I still haven't had a chance to attempt your suggestion.  If you have an understanding of how the Look up box is used could you give me a code snippet?
George TokasCommented:
>>Communication takes place over a VME or PCI buss....  
That means a physical (kind of) I/O Address??
If yes a lot of things can be speed up and solved using TIOPort component from
That means reading AND writing...
There is also and TComPort from the same company for using serial communication (COM ports or USB)...
Both components served me well during the past 4 years...
Maybe I need more details to came up with a workaround...

graberAuthor Commented:
Thanks George but per customer we are currently going ip
You dont actually have to even write any code to use a DBLookupComboBox.

It has a Data Source and DateField just the same as the regular DBCombo that you link to the data source and field you want to edit.

Then you need a 2nd DataSource to provide the 'lookup' that will automatically populate the drop down.  If you check the DBLookupComboBox it has a ListSource , which you link to the 2nd DataSource,  ListField which is the field it will use to populate the dropdown alone with a ListFieldIndex which determines the order.

Then you also see a KeyField and KeyValue  The KeyField is the field that is matching up between the 2nd and first DataSources.  The KeyValue is the actual value that is currently selected from the dropdown.  So what is displayed and what is actually going to be set do not need to be the same field BUT the KeyField must match the type of the ListField since that is what is actually being edited/set by the control.

So you can use a query as the ListSource or apply a filter to it to control what will show up in the drop down.  I usually actually populate DBCombo dropdowns manually but I also have a preference for the level of control that you get by not using DB aware controls.  More work but sometimes DB aware controls can have poor performane esp for networked databases.

A 'example' might be to have a address list where the 'Town/City' value is going to come from a dropdown.  So you would link up the address table as the ListSource with 'Town' for the ListField.  Then have a seperate table which contains a list of all the towns.  This would be the KeySource using the 'Town Name' as the KeyField.  Likely you would use the same field for the ListField also.

Now the power comes in that your town list database might also have further fields like say 'State'.  In which case you could fitler the 'ListSource' based on a particular state so the drop down only shows town names for say Texas by checking the value for 'State' from the ListSource.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
graberAuthor Commented:
Thanks..  There are so many options associated with the TDBLookupComboBox I never did make any headway with it.  Your explaination was great.  There is one last part to this and I'll wrap it up.  I noticed that was on OnChange event for this class.  There is an onClose for the mouse interface.  I tried the OnKey<press type> event but the break never caught it.  Any input?  And Kode thanks again.  You saved me alot of coding.
You may need to use the OnKeyDown event.  OnKeyPress only works for ANSI character keys.  Depends on exactly what keystroke you are trying to catch.

OnChange will fire every time you make a single keystroke change to the field which may or may not be useful.

Sometimes I use the OnExit event to do processing after somebody has made a selections.  If i recall one problem with this combo was that it does not fire an event to indicate you actually have selected a item.  A lot of the 3rd party drop down components have a OnAccept event which is really handy.

All depends on exactly what the end result you need is.
graberAuthor Commented:
kode this works great I put a data set and data source on to the form and it's pretty slick.  I did hit a snag.  I can only create 62 of these forms before I'm hit with an exception.  If I remove the database elements I can create more.  No the data sets have there own connection strings and I got to wondering if I was creating more db connection than Jet or some other database element could handle.  I am going to start another thread and wanted to give you a heads up.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.