lcl: implement ScrollListDataset in DBLookup controls

git-svn-id: trunk@34389 -
This commit is contained in:
blikblum 2011-12-24 15:03:24 +00:00
parent daea252a34
commit 15f1e374c6
4 changed files with 10 additions and 4 deletions

View File

@ -156,7 +156,7 @@ Type
destructor Destroy; override;
procedure Initialize(AControlDataLink: TFieldDataLink; AControlItems: TStrings);
function KeyFieldValue: Variant;
procedure UpdateData(ValueIndex: Integer);
procedure UpdateData(ValueIndex: Integer; ScrollDataset: Boolean);
function GetKeyValue(ValueIndex: Integer): Variant;
function GetKeyIndex: Integer;
function GetKeyIndex(const AKeyValue: Variant): Integer;
@ -419,6 +419,7 @@ Type
TDBLookupListBox = class(TCustomDBListBox)
private
FLookup: TDBLookup;
FScrollListDataset: Boolean;
procedure ActiveChange(Sender: TObject);
function GetKeyField: string;
function GetKeyValue: Variant;
@ -485,6 +486,7 @@ Type
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ScrollListDataset: Boolean read FScrollListDataset write FScrollListDataset default False;
property ShowHint;
property Sorted;
// property Style;
@ -739,6 +741,7 @@ Type
TDBLookupComboBox = class(TCustomDBComboBox)
private
FLookup: TDBLookup;
FScrollListDataset: Boolean;
procedure ActiveChange(Sender: TObject);
function GetKeyField: string;
function GetKeyValue: variant;
@ -819,6 +822,7 @@ Type
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ScrollListDataset: Boolean read FScrollListDataset write FScrollListDataset default False;
property ShowHint;
property Sorted;
property Style;

View File

@ -328,7 +328,7 @@ begin
Result := Null;
end;
procedure TDBLookup.UpdateData(ValueIndex: Integer);
procedure TDBLookup.UpdateData(ValueIndex: Integer; ScrollDataset: Boolean);
var
I: Integer;
Key: Variant;
@ -351,6 +351,8 @@ begin
for I := 0 to FDataFields.Count -1 do
TField(FDataFields[I]).Value := Key[I];
end;
if ScrollDataset then
FListLink.DataSet.Locate(FKeyFieldNames, Key, []);
end;
function TDBLookup.GetKeyValue(ValueIndex: Integer): Variant;

View File

@ -39,7 +39,7 @@ begin
ItemIndex := Items.IndexOf(Text);
i := ItemIndex;
if i <> -1 then
FLookup.UpdateData(i)
FLookup.UpdateData(i, FScrollListDataset)
else
Text := '';
end;

View File

@ -33,7 +33,7 @@ procedure TDBLookupListBox.UpdateData(Sender: TObject);
begin
if (ItemIndex < 0) then
Exit;
FLookup.UpdateData(ItemIndex);
FLookup.UpdateData(ItemIndex, FScrollListDataset);
end;
procedure TDBLookupListBox.ActiveChange(Sender: TObject);