Recent

Author Topic: TDBLookupComboBox strange behavior  (Read 2884 times)

bobkos

  • New Member
  • *
  • Posts: 32
    • Personal Finance Manager
TDBLookupComboBox strange behavior
« on: March 03, 2018, 01:54:03 pm »
Hello Collegues,

After update to Lazarus 1.8.2 I found strange behavior of TDBLookupComboBox. I'm trying to select the item, but with no success, however with the same code compiled with 1.8.0 works fine. Please see small video.

https://youtu.be/YLlBmegPfQ4

Are you have any ideas?
Thank you in advance.


taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TDBLookupComboBox strange behavior
« Reply #1 on: March 03, 2018, 02:16:47 pm »
works as designed. Either set the auto edit of DataSource1.dataset to true. or set the DBLookupComboBox1.DataSource to nil.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

bobkos

  • New Member
  • *
  • Posts: 32
    • Personal Finance Manager
Re: TDBLookupComboBox strange behavior
« Reply #2 on: March 03, 2018, 02:24:05 pm »
Thanks, but it doesn't help.
Please try code attached in post above under 1.8.2.

wp

  • Hero Member
  • *****
  • Posts: 13397
Re: TDBLookupComboBox strange behavior
« Reply #3 on: March 03, 2018, 03:01:10 pm »
Your DBLookUpCombobox has ReadOnly = true which was ignored in 1.8. It was fixed recently and probably made it into 1.8.2. But if you set it to false your demo crashes in DBLookupCombo.UpdateData and, further down to road, in TCustomBufdataset.Locate.

rvk

  • Hero Member
  • *****
  • Posts: 6948
Re: TDBLookupComboBox strange behavior
« Reply #4 on: March 03, 2018, 03:16:00 pm »
The reason for crashing when setting readonly to false is that TDBLookupComboBox is supposed to supply it's chosen value to another dataset.

It takes the values from ListSource>ListField and applies the chosen value to DataSource>DataField. You have them pointing to the same dataset which gives a circular reference (bound to give problems).

If you want to use a lookuptable without applying the chosen field to some dataset you should leave datasource and datafield empty and work with TDBLookupComboBox in "unbound" state.

see http://wiki.freepascal.org/TDBLookupComboBox

bobkos

  • New Member
  • *
  • Posts: 32
    • Personal Finance Manager
Re: TDBLookupComboBox strange behavior
« Reply #5 on: March 03, 2018, 04:49:47 pm »
Thank you all, now it's clear.
ReadOnly was an issue in original source code, and yes, I made a mistake with the DataSource loop in demo application.

 

TinyPortal © 2005-2018