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.
LVL 2
graberAsked:
Who is Participating?
 
kode99Commented:
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.

0
 
graberAuthor Commented:
Just checked the borland sight and this is exactly the case.  Can any one fill in the gaps as to why?
Thanks
0
 
kode99Commented:
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.

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
graberAuthor Commented:
thanks kode I'll give it a try.
0
 
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.

George.
0
 
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?
Gregg
0
 
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 www.winsoft.sk
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...

George.
0
 
graberAuthor Commented:
Thanks George but per customer we are currently going ip
0
 
graberAuthor Commented:
Kode
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.
Gregg
0
 
kode99Commented:
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.
0
 
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.
Thanks.
Gregg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.