• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • Last Modified:

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? :-(
0
jaja2005
Asked:
jaja2005
2 Solutions
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now