Change ChildManager at runtime
Posted: Sun Apr 11, 2010 4:56 pm
Hi,
Delph 2007 and Teetree2 included Teechart Pro VCL 8.04
I try change presentation of Tree by (Explorer, Left , Top or ListView) , at runtime but i have exception.
What is the best practice in this subject ??
My code ================================================================
function TreePrepareManager(ATree:TTree;AChildManager:TObject):integer;
begin
if ATree=nil then exit;
try
// Typ de tree Explorateur ; top ; Left ; ListView (PB not ancestor common!!)
if (AChildManager is TTreeExplorerAlignChild) then
ATree.ChangeManager(AChildManager as TTreeExplorerAlignChild)
else if AChildManager is TTreeTopBottomAlignChild then
ATree.ChangeManager(AChildManager as TTreeTopBottomAlignChild)
else if AChildManager is TTreeLeftRightAlignChild then
ATree.ChangeManager(AChildManager as TTreeLeftRightAlignChild)
else if AChildManager is TTreeListViewAlignChild then
ATree.ChangeManager(AChildManager as TTreeListViewAlignChild);
Except
CT_ERR.Push('U_TreeEfc.pas : Procedure PrepareChildManager'); Raise; // exception vioalion access !!!
End;
end;
in my forms========================================
constructor TFrameEfcTree.Create(AOwner: TComponent);
begin
inherited;
// Format of the tree
ChildExplorateur :=TTreeExplorerAlignChild.Create;
ChildTop :=TTreeTopBottomAlignChild.Create;
ChildLeft :=TTreeLeftRightAlignChild.Create;
ChildList :=TTreeListViewAlignChild.Create;
Tree1.AssignParent:=True;
ChildEnCours := ChildExplorateur; // ChildEnCours is Tobject
end;
procedure TFrameEfcTree.BtExploClick(Sender: TObject);
begin
Tree1.Clear;
ChildEnCours := ChildExplorateur;
TreePrepareManager(Tree1, ChildEnCours );
end;
procedure TFrameEfcTree.BtLeftClick(Sender: TObject);
begin
Tree1.Clear;
ChildEnCours := ChildLeft;
TreePrepareManager(Tree1, ChildEnCours );
end;
But, in first test is OK, but if change 2 o 3 > exception !!
Delph 2007 and Teetree2 included Teechart Pro VCL 8.04
I try change presentation of Tree by (Explorer, Left , Top or ListView) , at runtime but i have exception.
What is the best practice in this subject ??
My code ================================================================
function TreePrepareManager(ATree:TTree;AChildManager:TObject):integer;
begin
if ATree=nil then exit;
try
// Typ de tree Explorateur ; top ; Left ; ListView (PB not ancestor common!!)
if (AChildManager is TTreeExplorerAlignChild) then
ATree.ChangeManager(AChildManager as TTreeExplorerAlignChild)
else if AChildManager is TTreeTopBottomAlignChild then
ATree.ChangeManager(AChildManager as TTreeTopBottomAlignChild)
else if AChildManager is TTreeLeftRightAlignChild then
ATree.ChangeManager(AChildManager as TTreeLeftRightAlignChild)
else if AChildManager is TTreeListViewAlignChild then
ATree.ChangeManager(AChildManager as TTreeListViewAlignChild);
Except
CT_ERR.Push('U_TreeEfc.pas : Procedure PrepareChildManager'); Raise; // exception vioalion access !!!
End;
end;
in my forms========================================
constructor TFrameEfcTree.Create(AOwner: TComponent);
begin
inherited;
// Format of the tree
ChildExplorateur :=TTreeExplorerAlignChild.Create;
ChildTop :=TTreeTopBottomAlignChild.Create;
ChildLeft :=TTreeLeftRightAlignChild.Create;
ChildList :=TTreeListViewAlignChild.Create;
Tree1.AssignParent:=True;
ChildEnCours := ChildExplorateur; // ChildEnCours is Tobject
end;
procedure TFrameEfcTree.BtExploClick(Sender: TObject);
begin
Tree1.Clear;
ChildEnCours := ChildExplorateur;
TreePrepareManager(Tree1, ChildEnCours );
end;
procedure TFrameEfcTree.BtLeftClick(Sender: TObject);
begin
Tree1.Clear;
ChildEnCours := ChildLeft;
TreePrepareManager(Tree1, ChildEnCours );
end;
But, in first test is OK, but if change 2 o 3 > exception !!