LCL: Deprecated TDBLookupComboBox DropDownCount property in favor of DropDownRows to improve delphi compatibility, issue #35864

This commit is contained in:
Jesus Reyes A 2021-08-25 00:58:24 -05:00
parent 976c56ef7c
commit 1e64a65808
2 changed files with 30 additions and 3 deletions

View File

@ -860,12 +860,14 @@ Type
TDBLookupComboBox = class(TCustomDBComboBox)
protected
procedure DefineProperties(Filer: TFiler); override;
function DoEdit: boolean; override;
function IsUnbound: boolean;
private
FLookup: TDBLookup;
procedure ActiveChange(Sender: TObject);
function GetDisplayEmpty: String;
function GetDropDownRows: Integer;
function GetEmptyValue: String;
function GetKeyField: string;
function GetKeyValue: variant;
@ -875,7 +877,9 @@ Type
function GetLookupCache: boolean;
function GetNullValueKey: TShortCut;
function GetScrollListDataset: Boolean;
procedure ReadDropDownCount(Reader: TReader);
procedure SetDisplayEmpty(AValue: String);
procedure SetDropDownRows(AValue: Integer);
procedure SetEmptyValue(AValue: String);
procedure SetKeyField(const Value: string);
procedure SetKeyValue(const AValue: variant);
@ -899,6 +903,7 @@ Type
public
constructor Create(AOwner: TComponent); override;
property KeyValue: variant read GetKeyValue write SetKeyValue;
property DropDownCount; deprecated 'Use DropDownRows';
published
property Align;
property Anchors;
@ -920,7 +925,7 @@ Type
property DragCursor;
property DragKind;
property DragMode;
property DropDownCount;
property DropDownRows: Integer read GetDropDownRows write SetDropDownRows default 7;
property Enabled;
property Font;
// property ItemHeight;

View File

@ -24,6 +24,7 @@ begin
EmptyValue := '';
DisplayEmpty := '';
FDataLink.OnActiveChange := @ActiveChange;
inherited DropDownCount := 7;
end;
procedure TDBLookupComboBox.UpdateData(Sender: TObject);
@ -43,6 +44,12 @@ begin
UpdateLookup;
end;
procedure TDBLookupComboBox.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('DropDownCount', @ReadDropDownCount, nil, false);
end;
function TDBLookupComboBox.DoEdit: boolean;
begin
if IsUnbound then begin
@ -73,7 +80,12 @@ begin
Result := FLookup.DisplayEmpty;
end;
function TDBLookupComboBox.GetEmptyValue: string;
function TDBLookupComboBox.GetDropDownRows: Integer;
begin
result := inherited DropDownCount;
end;
function TDBLookupComboBox.GetEmptyValue: String;
begin
Result := FLookup.EmptyValue;
end;
@ -169,7 +181,12 @@ begin
UpdateLookup;
end;
procedure TDBLookupComboBox.SetEmptyValue(AValue: string);
procedure TDBLookupComboBox.SetDropDownRows(AValue: Integer);
begin
inherited DropDownCount := AValue;
end;
procedure TDBLookupComboBox.SetEmptyValue(AValue: String);
begin
FLookup.EmptyValue:=AValue;
UpdateLookup;
@ -180,6 +197,11 @@ begin
Result := FLookup.ScrollListDataset;
end;
procedure TDBLookupComboBox.ReadDropDownCount(Reader: TReader);
begin
inherited DropDownCount := Reader.ReadInteger;
end;
procedure TDBLookupComboBox.SetKeyField(const Value: string);
begin
FLookup.KeyField := Value;