TDBComboBox showing only one row? lazarus / 16-Databases ---------------------------------------------------------------------- tatamata · 2007-06-11 16:42 Hello. Lazarus 0.9.22, Windows XP, PostgreSQL 8.2., ZEOS components. TDBComboBox is driving me crazy! I just can't figure out how to get all rows from table into the combobox list. It always shows only one value (the first record), and I can't retrieve other values. If I drop-down, the list is empty. When I navigate through the same dataset, by using TDBGrid, TDBComboBox changes it's current value, respectively. But the list is empty, whenever I drop down the combobox. So, it seems that TDBComboBox is behaving like a textbox, showing always only current record's value. Is this a bug, or I am clumsy? Regards, Zlatko ---------------------------------------------------------------------- DougNettleton · 2007-06-11 18:47 Zlatko: Are you aware that you have to fill in the "Items" that will appear in the drop down list?  I just tried it with MySQL 5.0 connection, a SQLTranaction, a SQLQuery, a DataSource, a DBComboBox and a DBNavigator, using last night's snapshot for windows 32-bit and it works as I expected. HTH, Doug ---------------------------------------------------------------------- tatamata · 2007-06-11 20:07 Hi, Doug. No, I didn't know that I have to set Items, if I have already connected TDBComboBox to a dataset, by setting DataSource and DataField properties of the combobox. I thought it would be similar to TDBGrid... What exactly should I enter in Items TStringList? I tried to put a table field name, but a string appears as an item in combobobx. That's not what I want to accomplish. Basically, I want all values of a particular field of a dataset to be represented as combobox values in dropdown list, so that I can choose a value (item) and the dataset cursor goes to the corresponding row. Can it be done by setting items property, or I need to fill items through code? Thanks, Zlatko ---------------------------------------------------------------------- DougNettleton · 2007-06-11 21:41 Zlatko: You can fill the items with code, but this may not what you want do. Assume you have a person table with several address fields - one of which is province / state - I'm in North America.  You may want to have a separate table with State / Province code and their corresponding description.  As you browse through your "person table" you may want to look-up their province / state code and display the description and use the pull-down list to allow selection by the user friendly description.  If this is the functionality you want, you want a DBLookupComboBox.  This is not currently impemented in Lazarus as far as I know. Years ago in the pre- 15Meg program days, I used to be amazed that there wasn' a component in Delphi that worked like a combnation of a DBRadioGroup and a DBComboBox - so you could have say a marital status: S - Single M - Married D - Divorced W - Widow(er) U - Unknown You'd define the "items" Single / Married / Divorces / Widow(er) / Unknown and "Values" S / M / D / W / U like a DBRadioGroup but the display would only take up 1 line like a DBComboBox unless you clciked the drop down arrow.  Internally, you'd store the 1 character codes and present to the user the friendly description. Such a control, you could "load with code" for small static lookup tables, but alas ... HTH, Doug P.S. if you successfully create your own DBLookupComboBox don't be shy.  It would be a welcome additon to Lazarus. ---------------------------------------------------------------------- tatamata · 2007-06-12 04:56 Oh, it seems that I completely misunderstood DBComboBox behavior! I thought that combobox READS items from Datasource/DataField, while it actually WRITES TO DataField/DataSource from items! (I was searching in some books this sleepless night, to clarify this to me:)). That's because I'm currently switching from MS Access, where combobox behaves in both ways. It can be used both from reading from and writing to a field in a table. It could be similar to DBLookupCombo, I think. I was using this dual behavior of comboboxes in Access for fast jumping to a row in a form's recordset (instead of iteration), by synchronizing form's recordset with combobox recordset. (recordset cloning, bookmarks etc.). It needed only several lines of code. I suppose it is possible to get such behavior by some hard-coding in Lazarus (someone suggests me some direction?). Regarding creating DBLookupComboBox, hm, hm, hm, I wish I was so smart to be able to do that, but my current knowledge is so, so, limited:). Best regards, Zlatko