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

View File

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