LCL: Fix some data control regressions. Issue #35458, patch from Michal Gawrycki.

git-svn-id: trunk@61111 -
This commit is contained in:
juha 2019-05-03 13:53:21 +00:00
parent 1d8e8b2751
commit 7de7e2642e
2 changed files with 17 additions and 8 deletions

View File

@ -473,6 +473,7 @@ Type
procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override; procedure Loaded; override;
procedure UpdateData(Sender: TObject); override; procedure UpdateData(Sender: TObject); override;
function IsUnbound: boolean;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
property KeyValue: Variant read GetKeyValue write SetKeyValue; property KeyValue: Variant read GetKeyValue write SetKeyValue;

View File

@ -30,6 +30,11 @@ begin
FLookup.UpdateData(ItemIndex, FScrollListDataset); FLookup.UpdateData(ItemIndex, FScrollListDataset);
end; end;
function TDBLookupListBox.IsUnbound: boolean;
begin
Result := (FDataLink.DataSource = nil) or (DataField = '');
end;
procedure TDBLookupListBox.ActiveChange(Sender: TObject); procedure TDBLookupListBox.ActiveChange(Sender: TObject);
begin begin
if FDataLink.Active then if FDataLink.Active then
@ -54,15 +59,18 @@ end;
procedure TDBLookupListBox.DoSelectionChange(User: Boolean); procedure TDBLookupListBox.DoSelectionChange(User: Boolean);
begin begin
if User then if User then
begin if IsUnbound then
if FDataLink.CanModify then UpdateData(Self)
begin
FDataLink.Modified;
FDataLink.UpdateRecord;
end
else else
DataChange(Self); begin
end; if FDataLink.CanModify then
begin
FDataLink.Modified;
FDataLink.UpdateRecord;
end
else
DataChange(Self);
end;
inherited DoSelectionChange(User); inherited DoSelectionChange(User);
end; end;