lcl: move Lookup initialization from InitializeWnd to Loaded. Just update Items address in InitializeWnd. This allows KeyValue work between Loaded and handle creation

git-svn-id: trunk@34724 -
This commit is contained in:
blikblum 2012-01-13 00:35:34 +00:00
parent 5010a42914
commit 7ebde037c3
3 changed files with 19 additions and 2 deletions

View File

@ -160,6 +160,7 @@ Type
function GetKeyValue(ValueIndex: Integer): Variant;
function GetKeyIndex: Integer;
function GetKeyIndex(const AKeyValue: Variant): Integer;
property ControlItems: TStrings read FControlItems write FControlItems;
property LookupCache: boolean read FLookupCache write SetLookupCache;
// properties to be published by owner control
// these are not used where data control Field is dbLookup
@ -441,6 +442,7 @@ Type
procedure DoSelectionChange(User: Boolean); override;
procedure InitializeWnd; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure UpdateData(Sender: TObject); override;
public
constructor Create(AOwner: TComponent); override;
@ -762,6 +764,7 @@ Type
procedure CloseUp; override;
procedure InitializeWnd; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure UpdateData(Sender: TObject); override;
procedure DataChange(Sender: TObject); override;
procedure Select; override;

View File

@ -79,10 +79,17 @@ begin
inherited KeyDown(Key, Shift);
end;
procedure TDBLookupComboBox.Loaded;
begin
inherited Loaded;
UpdateLookup;
end;
procedure TDBLookupComboBox.InitializeWnd;
begin
inherited InitializeWnd;
UpdateLookup;
//after handle allocation Items address changes
FLookup.ControlItems := Items;
end;
function TDBLookupComboBox.GetKeyField: string;

View File

@ -62,7 +62,8 @@ end;
procedure TDBLookupListBox.InitializeWnd;
begin
inherited InitializeWnd;
UpdateLookup;
//after handle allocation Items address changes
FLookup.ControlItems := Items;
end;
procedure TDBLookupListBox.KeyDown(var Key: Word; Shift: TShiftState);
@ -77,6 +78,12 @@ begin
inherited KeyDown(Key, Shift);
end;
procedure TDBLookupListBox.Loaded;
begin
inherited Loaded;
UpdateLookup;
end;
function TDBLookupListBox.GetKeyField: string;
begin
Result := FLookup.KeyField;