JohnLM 14 Posted August 7 (edited) Specs: Delphi XE7, vcl, win7 - Firedac, Ms Access database and DBListbox - database name, "data.mdb" I created in MS Access. To my surprise, I found that I cannot view data in real-time in a DBListbox at design-time. I can only view data in real-time at design-time when using the DBGrid. Is this true or am I missing something in my connections or setting during design-time ? I've been struggling with this since yeterday and don't know what else to do. The following is the connection setup that I am working with. At design-time It works with the DBGrid, but not the DBListbox. Connection -> Datasource -> Qry -> DBListbox Edited August 7 by JohnLM Share this post Link to post
Brian Evans 105 Posted August 7 (edited) You need to put the list of values to choose from in the list's items property. Quote TDBListBox represents a data-aware list box that allows users to change field values by selecting an item from a list. Use TDBListBox to add a list box to a form that permits users to change the value of a field on the current record to one of a fixed set of choices. If you want the list of values to come from the database you would use a DBLookupListBox. Edited August 7 by Brian Evans Share this post Link to post
JohnLM 14 Posted August 7 If I go to the DBLisBox's items (TStrings) and add my fields to it (mdate, title, name), then all that does is show those strings and nothing more in design-time. They do not show my actual data for those fields. Also, to note, I am not trying to show a grid of data in a DBListBox. I am trying to show one field's values, which is mdate. So it does appear that the DBListbox (and DBComboBox, DBLookupListBox) do not support real-time view at design-time, only the DBGrid supports that feature. Share this post Link to post
Brian Evans 105 Posted August 7 (edited) It shows live data. For ONE field of ONE record (the current record of the dataset) it shows a list of values (from the items property) with the current field value highlighted. A customer record might have a Country field: hooking it up with the list having values for Canada, USA, Mexico it would highlight the list value matching that of the current record. If the user clicked a different list value, then the field would change value to that. Edited August 7 by Brian Evans Share this post Link to post
JohnLM 14 Posted August 7 (edited) You must be in a higher Delphi version because those features do not exist in my Delphi XE7 (Firedac installed) Update 1. The Items property in my version for the DBListBox is for TStrings values. It shows a blank screen when I click the [...] box. Edited August 7 by JohnLM Share this post Link to post
Brian Evans 105 Posted August 7 (edited) You must manually enter the "fixed set of choices" that populate the list. Just like an TDBEdit shows one field value from the current record the TDBListBox highlights the value of one field from the current record in the list. A DBLookupListBox also sources the values for the list from another query / datasource. Edited August 7 by Brian Evans Share this post Link to post
JohnLM 14 Posted August 7 In XE7, I do not see any place that shows 'fixed set of choices' or a place to enter said choices. All the controls that you see populated are using the db controls Datasource: ds and DataField: mdate but dblistbox fails to show when using the same setup. I don't know how else to explain it. Share this post Link to post
JohnLM 14 Posted August 7 (edited) The only answer that I can come up with is that this was a bug in the DBListBox for XE7 Update 1, and it may have never been reported/resolved and/or it was fixed in a newer version, i.e., XE8 and up and no mention of this bug. I have XE7 with the Firedac Add-on pack installed. I don't know which version they stopped the firedack add-on packs and just included it in the complete installation. Edited August 7 by JohnLM Share this post Link to post
Brian Evans 105 Posted August 7 49 minutes ago, JohnLM said: In XE7, I do not see any place that shows 'fixed set of choices' or a place to enter said choices. Items. Share this post Link to post
JohnLM 14 Posted August 7 Okay, I think I now understand it and how it works. The short answer: I have to manually fill in the field type data into the Items property. When the Datasource and Datafield are connected, when I move up/down in the dblistbox, the other fields will sync and move accordingly. So, if I have a Date field, and two string fields (i.e., mdate, title, name) in my data.mdb database and I want to create a picklist or selection list via a DBListBox control, I must add the dates in manually (or import them through another means--i won't go into here) and populate the Items property with those dates, run the app and the data should sync up. A DBNavigator might come in handy here. But, if I want to use the Title field instead, in the dblistbox as a picklist/selection list, I must enter manually (or via an import), the Titles into the Items property, run the app, and have the same outcome. Share this post Link to post
JohnLM 14 Posted August 7 (edited) I tried this in both D12 and XE7 and the same outcome. So, no bug in DBListBox. Its just a odd way of creating a picklist. I think the DBLookupBox is the better way because I can link the Date, Title or Name field in the lookupbox and in real-time/live data will show at design-time. Yes, I discovered how to successfully do it with a DBLookupBox. And that's the route I will take. Edited August 7 by JohnLM Share this post Link to post