I have a DBLookupComboBox that is wired to a database query. That part is working fine. When I run the program the DBLookupComboBox is populated with the results of the query. I'd like to to see the DBLookupComboBox populated with the first item "Please Select" when the program first runs or when a new item action is initiated. (See below image)
Also, if I'm loading a previously saved database record that had selected Index 2 "Quick Elimination" how would I get the DBLookupComboBox to display that selected entry?
Yes, "Please Select" is index 0 and it is retreived as part of the query.
Databases - Delphi - DBLookupComboBox The DBLookupComboBox provides a simple way to associate a long descriptive name (stored in a lookup table) with a short (or numeric) key. When used with the KADao components, DBLookupComboBox's work fine - they display all related records.
Select the "Data controls" page on the Component Palette and pick a DBLookupComboBox. Drop one anywhere on the form and leave the default name of "DBLookupComboBox1."
To show a DBLookupComboBox inside a cell of a DBGrid, you first need to make one available at run time... Select the "Data controls" page on the Component Palette and pick a DBLookupComboBox. Drop one anywhere on the form and leave the default name of "DBLookupComboBox1."
As stated above, when your data entry form is made of more data controls DBEdit, DBComboBox, etc. it makes sense to just use DBLookupComboBox without creating.
You could try this (I know you've probably solved it by now, as you asked over 2 years ago), but in case anyone else was interested...
dbluLookup.KeyValue := dbluLookup.ListSource.DataSet.FieldByName(dbluLookup.KeyField).Value;
That simply sets KeyValue to the first record in the ListSource dataset, which should be the row 'Please Select'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With