Page 1 of 2
Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 05.05.2023, 21:48
by rrricci
Hello friends, I have notice that on Lazarus 2.2.4 or above, on the TzUpdateSQL component, the existing update fields are not been selectec when we double click the component. Please see attachment. I wonder if this is a new behavior or a simple bug. On my earlier lazarus version all fields were selected automatically as we defined the last time we edited the component.
Note: Also tested with Zeoslib 8.x. Same behavior.
Thanks.
Renato Ricci
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 11.05.2023, 08:41
by marsupilami
Hello Renato,
currently this is a known issue that I cannot fix. There are other bugs that have to be fixed first.
With best regards,
Jan
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 11.05.2023, 19:54
by rrricci
marsupilami wrote: ↑11.05.2023, 08:41
Hello Renato,
currently this is a known issue that I cannot fix. There are other bugs that have to be fixed first.
With best regards,
Jan
Hello Jan.. Thanks for the feedback.. For now I will keep with the previous version..
Thanks and good luck!
Renato
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 25.07.2023, 15:40
by rrricci
Hi friends.. any news about this bug? Is there any patch?
Thanks
Renato
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 26.07.2023, 07:41
by marsupilami
Hello Renato,
unfortunately - no. There simply was no time to look at it yet.
With best regards,
Jan
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 09.08.2023, 20:59
by rrricci
marsupilami wrote: ↑26.07.2023, 07:41
Hello Renato,
unfortunately - no. There simply was no time to look at it yet.
With best regards,
Jan
If you would like to, you can give me some tips where to look around in the code and I'll try to fix it, and then I'll post you back the solution.
PS: Using Lazarus 2.2.6 / FPC 3.2.2
Thanks.
Renato
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 10.08.2023, 10:33
by marsupilami
Hello Renato,
I think the starting point for thius would be ZUpdateSqlEditor.pas in src\component. I assume, it contains the editor window for TZUpdateSQL. I didn't work on that code (yet) so I don't know what it looks like in there.
Best regards,
Jan
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 12.01.2024, 18:44
by singlesis
Same problem here utilizing Lazarus 3.0.. is there any patch to correct it? Tks.
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 13.01.2024, 15:58
by marsupilami
Hello singlesis,
unfortunately there is no patch yet.
With best regards,
Jan
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 06.09.2024, 14:57
by rrricci
Hello.. I think I found the solution.. Please validade it..
At file ZUpdateSqlEditor.pas in src/component I have commented out the 2 lines below and it worked, cause does not make sense the component set selected(i) = true and later on it set the itemindex equals 0. (will loose the selection right?). Please check if this is the correct berravior, since as I said, I am not so experient on the component.
1. ListBox.ItemIndex := 0;
2. ListBox.TopIndex := 0;
Code: Select all
function SetSelectedItems(ListBox: TListBox; List: TStrings): Integer;
var
I: Integer;
begin
Result := 0;
ListBox.Items.BeginUpdate;
try
for I := 0 to ListBox.Items.Count - 1 do
if List.IndexOf(ListBox.Items[I]) > -1 then
begin
ListBox.Selected[I] := True;
Inc(Result);
end
else
ListBox.Selected[I] := False;
if ListBox.Items.Count > 0 then
begin
//ListBox.ItemIndex := 0;
//ListBox.TopIndex := 0;
end;
finally
ListBox.Items.EndUpdate;
end;
end;
Also commented the 2 lines at 'SelectAll' procedure:, witch is related to the popup menu..
Code: Select all
procedure SelectAll(ListBox: TListBox);
var
I: Integer;
begin
ListBox.Items.BeginUpdate;
try
with ListBox do
for I := 0 to Items.Count - 1 do
Selected[I] := True;
if ListBox.Items.Count > 0 then
begin
//ListBox.ItemIndex := 0;
//ListBox.TopIndex := 0;
end;
finally
ListBox.Items.EndUpdate;
end;
end;
Thanks.
Renato
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 06.09.2024, 15:02
by rrricci
Just a correction.. Also comment the block:
if ListBox.Items.Count > 0 then
begin
end;
Thanks
Renato Ricci
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 08.09.2024, 13:58
by aehimself
To be honest it's a little bit confusing for me as well. Individual items are (de)selected within the cycle and then we are moving the selection back to the first one? TopIndex alone would make sense IF it does not change selection.
Also what I can not understand, why we are selecting all items in ListBox by hand, if I'm 99% sure ListBox has a .SelectAll method...?
I'll fire up a Delphi 7 to confirm these.
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 08.09.2024, 14:35
by aehimself
I did a minimal example and I can confirm that
1, Under Delphi 7 TListBox has .Selected[], .TopIndex and .SelectAll methods
2, Setting .Selected[] or invoking .SelectAll indeed moves the node in question to be visible (they do scroll the scrollbox)
So, the below code is the most efficient and fool-proof way I can imagine:
Code: Select all
procedure TForm1.SelectRandomButtonClick(Sender: TObject);
Var
a: integer;
begin
ListBox1.Items.BeginUpdate;
Try
For a := 0 To ListBox1.Items.Count - 1 Do
ListBox1.Selected[a] := a Mod 2 = 0;
ListBox1.TopIndex := 0;
Finally
ListBox1.Items.EndUpdate;
End;
end;
procedure TForm1.SelectAllButonClick(Sender: TObject);
begin
ListBox1.Items.BeginUpdate;
Try
ListBox1.SelectAll;
ListBox1.TopIndex := 0;
Finally
ListBox1.Items.EndUpdate;
End;
end;
Screenshot_20240908_153626.png
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 09.09.2024, 09:50
by aehimself
Since it is 100% Delphi 7 compatible I issued a pull request on
GitHub. I don't have any real-world application to test it on though so I'll leave that to the community :)
Re: Lazarus - TZUpdateSQL not bringing its update fields selected
Posted: 09.09.2024, 15:51
by rrricci
Great!
Thanks aehimself!