Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-06

How to use DBCombobox

10 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

Hi,

I'm trying to use a DBCombobox, but I don't know how to show all records. Only the first record shows.
What I did :
Put an IBConnection on the form. Fill in the details. Put an SQLTransaction on the form.
Put an SQLQuery on the form and fill in the details about the table to use. Put a Datasource on the form.
Put a DBCombobox on the form.
To test I put a DBGrid on the form.
When I activate the SQL, I see some records filling the grid and the first record in the DBCombobox.
When I run the application, I can navigate to all records in the grid and I see the first record in the DBCombobox. But the drop down of the DBCombobox shows nothing so I can't select other records than the first.

I'm using Lazarus 0.9.30.4 with FPC 2.6.0.

What am I missing ?

Regards,

Koenraad Lelong.

Reply by email

Koenraad Lelong
to Koenraad Lelong
Koenraad Lelong wrote 21 lines
Hi, I'm trying to use a DBCombobox, but I don't know how to show all records. Only the first record shows. What I did : Put an IBConnection on the form. Fill in the details. Put an SQLTransaction on the form. Put an SQLQuery on the form and fill in the details about the table to use. Put a Datasource on the form. Put a DBCombobox on the form. To test I put a DBGrid on the form. When I activate the SQL, I see some records filling the grid and the first record in the DBCombobox. When I run the application, I can navigate to all records in the grid and I see the first record in the DBCombobox. But the drop down of the DBCombobox shows nothing so I can't select other records than the first. I'm using Lazarus 0.9.30.4 with FPC 2.6.0. What am I missing ?

No suggestions what I'm doing wrong ?

I enclose a project, using the employee-database.

Regards,

Koenraad Lelong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: laztest2.7z
Type: application/x-7z-compressed
Size: 60854 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120618/2f038016/attachment-0001.bin>

Reply by email

Koenraad Lelong
to Koenraad Lelong
Koenraad Lelong wrote 8 lines
No suggestions what I'm doing wrong ? I enclose a project, using the employee-database. Regards, Koenraad Lelong.

Hi,

I forgot to say that scrolling the grid makes the highlighted field of the grid appear in the combobox, but only that field is available, not other fields are visible.

Regards,

Koenraad Lelong.

Reply by email

Mattias Gaertner
to Koenraad Lelong: No suggestions what I'm doing wrong ? I enclose a project, using the employee-database.…
Show quoted text 26 lines
On 17-06-12 19:15, Koenraad Lelong wrote: > Hi, > > I'm trying to use a DBCombobox, but I don't know how to show all > records. Only the first record shows. > What I did : > Put an IBConnection on the form. Fill in the details. > Put an SQLTransaction on the form. > Put an SQLQuery on the form and fill in the details about the table to use. > Put a Datasource on the form. > Put a DBCombobox on the form. > To test I put a DBGrid on the form. > When I activate the SQL, I see some records filling the grid and the > first record in the DBCombobox. > When I run the application, I can navigate to all records in the grid > and I see the first record in the DBCombobox. But the drop down of the > DBCombobox shows nothing so I can't select other records than the first. > > I'm using Lazarus 0.9.30.4 with FPC 2.6.0. > > What am I missing ? > No suggestions what I'm doing wrong ? I enclose a project, using the employee-database.

TDBComboBox is for your own list of values.
Maybe you are looking for TDBLookupComboBox?

Mattias

Reply by email

Reinier Olislagers
to Koenraad Lelong: I forgot to say that scrolling the grid makes the highlighted field of the grid appear in…
Koenraad Lelong wrote 15 lines
On 18-06-12 11:28, Koenraad Lelong wrote: > > No suggestions what I'm doing wrong ? > > I enclose a project, using the employee-database. > > Regards, > > Koenraad Lelong. Hi, I forgot to say that scrolling the grid makes the highlighted field of the grid appear in the combobox, but only that field is available, not other fields are visible.

Apparently the combobox is bound to the CUSTOMER datafield in the datasource => the customer name field in the customers table. If you move down the grid, that is also linked to the datasource, the combobox value changes because the bound field changes. No idea what this dbcombobox is for... but my Delphi experience is near zero and imagination has not yet been too coffee-fuelled yet.

Try seeing if a DBLookupCombobox does what you want: it should let you select a value out of another table and insert that into the field bound to the dblookupcombobox.

Reply by email

Ludo Brands
to Koenraad Lelong: I forgot to say that scrolling the grid makes the highlighted field of the grid appear in…
Show quoted text 8 lines
Hi, I forgot to say that scrolling the grid makes the highlighted field of the grid appear in the combobox, but only that field is available, not other fields are visible.

I think you have a misunderstanding of what a DBCombobox does. It is a control that lets you edit the current record by entering data directly or by selecting from a pre-defined list. You are looking for a list that is populated from a table. That is TDBLookupComboBox.

Ludo

Reply by email

Koenraad Lelong
to Reinier Olislagers: Apparently the combobox is bound to the CUSTOMER datafield in the datasource => the…
Reinier Olislagers wrote
Try seeing if a DBLookupCombobox does what you want: it should let you select a value out of another table and insert that into the field bound to the dblookupcombobox.

Hi,

Just tried, it's worse. There absolutely nothing shows. I must be doing something wrong.

I'll switch to Delphi (again, frustrating).

Thanks.

Koenraad.

Reply by email

Reinier Olislagers
to Koenraad Lelong
Koenraad Lelong wrote 10 lines
On 18-06-12 11:44, Reinier Olislagers wrote: > > Try seeing if a DBLookupCombobox does what you want: it should let you > select a value out of another table and insert that into the field bound > to the dblookupcombobox. Hi, Just tried, it's worse. There absolutely nothing shows. I must be doing something wrong.

Explain what you want to do, give a sample of what failed up to now... My crystal ball says you bound the combobox to the field you want to edit but you haven't told the combobox in what other table to look up its data.

Reply by email

Reinier Olislagers
to Reinier Olislagers
Reinier Olislagers wrote 16 lines
On 18-6-2012 15:31, Koenraad Lelong wrote: > On 18-06-12 11:44, Reinier Olislagers wrote: >> >> Try seeing if a DBLookupCombobox does what you want: it should let you >> select a value out of another table and insert that into the field bound >> to the dblookupcombobox. > > Hi, > > Just tried, it's worse. There absolutely nothing shows. I must be doing > something wrong. Explain what you want to do, give a sample of what failed up to now... My crystal ball says you bound the combobox to the field you want to edit but you haven't told the combobox in what other table to look up its data.

... looking at the object inspector when having a dblookupcombobox selected shows listsource and listfield as interesting targets for that.

Reply by email