mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 21:20:30 +02:00
lcl: properly initialize keys for sorted lookup controls. Issue #23619
git-svn-id: trunk@41414 -
This commit is contained in:
parent
35ac6f51b9
commit
dfdab62ac2
@ -208,9 +208,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBLookup.FetchLookupData;
|
procedure SlideKeyList(var KeyList: array of Variant; Index, ListCount: Integer);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i := ListCount - 1 downto Index do
|
||||||
|
KeyList[i + 1] := KeyList[i];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDBLookup.FetchLookupData;
|
||||||
|
var
|
||||||
|
KeyIndex, KeyListCount: Integer;
|
||||||
ListLinkDataSet: TDataSet;
|
ListLinkDataSet: TDataSet;
|
||||||
begin
|
begin
|
||||||
if not Assigned(FControlItems) then
|
if not Assigned(FControlItems) then
|
||||||
@ -228,14 +236,21 @@ begin
|
|||||||
ListLinkDataSet.Last;
|
ListLinkDataSet.Last;
|
||||||
ListLinkDataSet.First;
|
ListLinkDataSet.First;
|
||||||
SetLength(FListKeys, ListLinkDataSet.RecordCount);
|
SetLength(FListKeys, ListLinkDataSet.RecordCount);
|
||||||
i := 0;
|
KeyListCount := 0;
|
||||||
while not ListLinkDataSet.EOF do
|
while not ListLinkDataSet.EOF do
|
||||||
begin
|
begin
|
||||||
FListKeys[i] := ListLinkDataSet.FieldValues[FKeyFieldNames];
|
KeyIndex := FControlItems.Add(FListField.DisplayText);
|
||||||
Inc(i);
|
//check if item was really added (in sorted list duplicate values are not added)
|
||||||
FControlItems.Add(FListField.DisplayText);
|
if FControlItems.Count > KeyListCount then
|
||||||
|
begin
|
||||||
|
if KeyIndex < KeyListCount then
|
||||||
|
SlideKeyList(FListKeys, KeyIndex, KeyListCount);
|
||||||
|
FListKeys[KeyIndex] := ListLinkDataSet.FieldValues[FKeyFieldNames];
|
||||||
|
Inc(KeyListCount);
|
||||||
|
end;
|
||||||
ListLinkDataSet.Next;
|
ListLinkDataSet.Next;
|
||||||
end;
|
end;
|
||||||
|
SetLength(FListKeys, KeyListCount);
|
||||||
finally
|
finally
|
||||||
LinkGotoBookMark;
|
LinkGotoBookMark;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user