TVirtualStringTree

I have several object tmyobject where one field is:

FMy: TVirtualStringTree;

I've created another form where i want to show this Virtual Tree and add others node with:


procedure TMyEditor.AddMonitorClick(Sender: TObject);
 var Data: PTreeData;
  XNode: PVirtualNode;
begin
    XNode:=vt.AddChild(nil);
    Data := Vt.GetNodeData(Xnode);
    Data^.TNode := TNode(node);
end;


I open this form with ShowDialog. I want to creare a sort of editor. In TmyEditor
there is already am virtual component which I have dragged from palette. Let's name
it vt. Should I first create FMy in Tmyobject and then link it to the one in MyEditor
so when I add nodes with the procedure above I am changing FMy?

Can you help me? :-(
jaja2005Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
I am currently looking into TVirtualStringTree to see if by some chance you could assign the whole tree data of one VT component to another using some kind of root node, but I have a feeling it's not possible.
Maybe experts who are used to this component can tell more about it.

What I usually do in your case is putting the component from the object you want to edit in a panel which name, position and size is set to what I want the TV edit component to be , and set the align=alClient. So the component is really displayed in the editor (but not owned by it)
You have to set all the events as well to events of your editor form. To simplify things, start with a TV component in your editor, implement it's events normally, which will create the event handlers in your form starting with the name of this component (TV...) and delete the component when you are done.


With ObjectToEdit.FMy do
 begin
  Parent:=pnlVTEditor;
  Align:=alClient;
  onChange:=VTChange;  // <== assign the onChange event to the TV of the object to edit
 end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaja2005Author Commented:
What I usually do in your case is putting the component from the object you want to edit in a panel which name, position and size is set to what I want the TV edit component to be , and set the align=alClient. So the component is really displayed in the editor (but not owned by it)

Amazing....
0
mbprogrammerCommented:
Try the following it may help:
1. Create your Tree.
2. when ever you want to show the editor form, first create the form, then chang the parent of the VTree to the new Form, then show the form, after you were done, change the parent of the VTree back to your first Form.

This may help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.