?
Solved

TDBComboBox shouldn't it be able to populate itself?

Posted on 2006-04-17
11
Medium Priority
?
1,103 Views
Last Modified: 2013-11-17
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.
0
Comment
Question by:graber
  • 6
  • 3
  • 2
11 Comments
 
LVL 2

Author Comment

by:graber
ID: 16472078
Just checked the borland sight and this is exactly the case.  Can any one fill in the gaps as to why?
Thanks
0
 
LVL 25

Expert Comment

by:kode99
ID: 16483441
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
 
LVL 2

Author Comment

by:graber
ID: 16493290
thanks kode I'll give it a try.
0
Technology Partners: 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!

 
LVL 16

Expert Comment

by:George Tokas
ID: 16512755
>>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
 
LVL 2

Author Comment

by:graber
ID: 16525056
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
 
LVL 16

Expert Comment

by:George Tokas
ID: 16526201
>>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
 
LVL 2

Author Comment

by:graber
ID: 16529734
Thanks George but per customer we are currently going ip
0
 
LVL 25

Accepted Solution

by:
kode99 earned 2000 total points
ID: 16531400
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
 
LVL 2

Author Comment

by:graber
ID: 16536477
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
 
LVL 25

Expert Comment

by:kode99
ID: 16542064
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
 
LVL 2

Author Comment

by:graber
ID: 16556569
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question