Recent

Author Topic: Is TdcComboBox working well in Lazarus 1.8?  (Read 3391 times)

nachoap

  • New Member
  • *
  • Posts: 22
Is TdcComboBox working well in Lazarus 1.8?
« on: December 22, 2017, 09:15:23 am »
Hi!

A couple of days ago I installed Lazarus 1.8 and migrated my applications to this version. I tested them and all was ok. Today I'm making some tests and I've found a problem: when I select an item in a TdbComboBox it doesn't change the value in the database. When I "post" the dataset it shows again the old value, and this old value remains in the table.

I've tried to do it programatically and it seems very strange too: first time it doesn't change the value and second time it works.

Quote
     if (qVisitas.State = dsEdit) or (qVisitas.State = dsInsert) Then
     begin
          qVisitas.FieldByName('DIFICULTAD_VISITA').AsInteger := StrToInt(dbcbDificultad.Items[dbcbDificultad.ItemIndex]);
     end
     else if qVisitas.RecordCount > 0 then
     begin
          qVisitas.Edit;
          qVisitas.FieldByName('DIFICULTAD_VISITA').AsInteger := StrToInt(dbcbDificultad.Items[dbcbDificultad.ItemIndex]);
          qVisitas.Post;
     end;

First time qVisitas is not in editing nor inserting state, so it goes to the second condition, it changes to Edit state, it changes the field and it posts. But nothing changes. In a second it returns to the old value.

If I try again, it executes the first condition ( :O), it changes the field and it works.

I'm lost. With Lazarus 1.6.4 it worked perfectly, without extra code. I pressed a value and it changed in the control and in the table.

Any suggestions? Thanks in advance

nachoap

  • New Member
  • *
  • Posts: 22
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #1 on: December 22, 2017, 01:42:47 pm »
I've the same problem in a diferent application. It worked all right until Lazarus 1.8.

Sqlite dabatase, zeos controls. When I change a value in a TDBComboBox it doesn't change when I post.

I have to change it two times in order it changes. :O

More tests: if I select two times, it works. And if I select first one TDBComboBox and afterwards other TDBComboBox different but linked to the same datasource... second TDBComboBox works well. If I change the order and select a value first in the second TDBCombo and afterwards in the first, first works well. First change is ignored.

It seems the initial state of DS is making TDBComboBox doesn't work. I don't know if is a problem of Lazarus or a Zeosdb fault

Later, I'll try to change zeos controls to a previous version.
« Last Edit: December 22, 2017, 02:02:10 pm by nachoap »

nachoap

  • New Member
  • *
  • Posts: 22
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #2 on: December 22, 2017, 08:32:13 pm »
I've programmed an easy and dirty example.

  • Try to change the value of one of the two DBComboboxes and afterwards press "post" (the green check mark in the navigation bar). It doesn't changes the value.
  • Try to insert a new row (button "+"), select a value in one dbcombobox and press "post". It doesn't work
  • Now try to select a value in one dbcombobox and afterwards in the other. Press "post". The value in the second combo remains and the other doesn't work
  • Select a value in a dbcombo. Select the same value (or a different value) in the SAME combo. It works

Quote
https://www.dropbox.com/s/p6xdoliqa5goiu0/LazError.zip?dl=0
« Last Edit: December 22, 2017, 08:35:21 pm by nachoap »

wp

  • Hero Member
  • *****
  • Posts: 12762
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #3 on: December 22, 2017, 10:38:49 pm »
Why did you turn off the option nbEdit of the VisibleButtons of the DBNavigator? You absolutely need this if you want to edit the record. And there should also be the nbCancel for the case that the user wants to discard his selection.

With these modifications your demo runs correctly in my opinion:
  • Run demo
  • Click '+' of the navigator to insert a new record.
  • Select a value from one or both comboboxes.
  • Click the green checkmark to save back to the table.
  • You can navigate with the arrow keys back and forth. You should find the new record again.
Or:
  • Click on the pencil icon to edit the current record.
  • Select a new value from one or both comboboxes
  • Click the green checkmark to save
  • Again navigate back and forth. You should find the modified record again.
If edit and insert modes are properly entered there will be no error messages.

nachoap

  • New Member
  • *
  • Posts: 22
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #4 on: December 23, 2017, 07:54:46 am »
Thanks for your answer, but it doesn't solve totally the problem.

I've changed these two properties and the problem remains without a complete solution. If I press the Edit button in the navigation bar, it works now. And if I press Insert it works too, but if I try to modify the selected value without pressing the Edit navigation button, it doens't work. It seems as if the dbcombobox doesn't entered in a "edit" state when I select a value as it entered in previous Lazarus versions.

This is the new executable with these two properties activated (true):

Quote
https://www.dropbox.com/s/ld2c7qxu09aost7/LazError_20171223_07.54.zip?dl=0

Try to change a value without pressing the edit button. Afterwards try to changing it two times. With two consecutive selections it works.

This code linked to the two OnClick dbcomboboxes event, solves the problem:

Quote
procedure TForm1.DBComboBox1Click(Sender: TObject);
begin
     (Sender As TDBComboBox).DataSource.DataSet.Edit;
end;

Quote
https://www.dropbox.com/s/9h5rxnmww69e3bn/LazError_Solved.zip?dl=0

Regards,

NAcho AP
« Last Edit: December 23, 2017, 08:08:17 am by nachoap »

wp

  • Hero Member
  • *****
  • Posts: 12762
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #5 on: December 23, 2017, 10:44:22 am »
You are talking of AutoEdit mode. Well, there is an AutoEdit of the TDataSource, and it is TRUE by default. If a add a TEdit to your demo I can modify its contents even if I don't click the navigator's edit button, as long as the TDatasource.AutoEdit is true. This is not possible with the TDBCombobox, and I agree now that this is a bug.

Please write a bug report and refer to this discussion.

miab3

  • Full Member
  • ***
  • Posts: 145
Re: Is TdcComboBox working well in Lazarus 1.8?
« Reply #6 on: December 23, 2017, 10:46:31 am »
There is an error.
RxDBComboBox is working properly.

Michal

 

TinyPortal © 2005-2018