Recent

Author Topic: [SOLVED] DBLookupComboBox don't select the ListSource record.  (Read 4169 times)

Galileo

  • New Member
  • *
  • Posts: 21
Hi All.
I'm trying to use a DBLookupComboBox and i can't get it work as expected.

I attached a little example to show the problem.
There are 2 DBF files Clientes (Clients) and Provincias (States).
The Clientes files has a field PROVINCIA_ with the state's id corresponding.

There are two forms. Form1 has a grid and an Edit button. Form2 show the edits fields
and a DBLookupcombobox loaded with Provincia's file.

By default, the DBLookupCombobox don't select the current Provincia.
If you uncomment the following line at event Show it works fine.

//DBLookupComboBox1.KeyValue:=Form1.Dbf_clientes.FieldByName('PROVINCIA_').AsInteger;

There are something else to configure in the DBLookupComboBox's properties to work by default?

I tryied it in Lazarus 1.6.2 in Linux (QT) and Windows 7 (native) and also in Lazarus 1.2.6 on Windows 7.

Thanks in advance.

Eduardo.
           
« Last Edit: March 17, 2017, 04:00:16 pm by Galileo »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: DBLookupComboBox don't select the ListSource record.
« Reply #1 on: March 16, 2017, 08:32:18 pm »
You need to give provincias.dbf a primary index on the ID field, and put the name of that index file in the appropriate property before primary-key-lookup based on that field will work as you want.

Galileo

  • New Member
  • *
  • Posts: 21
Re: DBLookupComboBox don't select the ListSource record.
« Reply #2 on: March 17, 2017, 03:59:53 pm »
Thank you howardpc!

It's working fine now.

Regards. Eduardo.

 

TinyPortal © 2005-2018