tzigi
asked on
Adding a new property (String) to a TreeNode.
Greetings,
How can I add a new property to a TreeNode object.
I must store additional information (string) for each node in a TreeView.
Thank you,
Tzigi
How can I add a new property to a TreeNode object.
I must store additional information (string) for each node in a TreeView.
Thank you,
Tzigi
ASKER
Thank you for your quick reply.
I know how to use the Data property, but my question was related to the concept of adding a property to an object that is dependent in other objects like in this situation the TreeView.
Can I change the TreeNode without changing the TreeView ?
Best Regards,
Tzigi.
I know how to use the Data property, but my question was related to the concept of adding a property to an object that is dependent in other objects like in this situation the TreeView.
Can I change the TreeNode without changing the TreeView ?
Best Regards,
Tzigi.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are correct LukA.
I gave it a try but .....
The TreeNode is used in too many Functions and Procedures.
I could change the source, but that would probably violate the copyright.
I'll try another approach.
Thank you.
I gave it a try but .....
The TreeNode is used in too many Functions and Procedures.
I could change the source, but that would probably violate the copyright.
I'll try another approach.
Thank you.
Thanks! You can always use the Data property as Cesario said...
you dont need to add any propteries to the node.
just use the Data Properties to store the String or other Information.
Simple example:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure TreeView1Deletion(Sender: TObject; Node: TTreeNode);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
VAR
Node : tTreeNode;
s : pString;
begin
Node := TreeView1.items.AddChild ( nil,'FirstNode');
new(s);
S^ := 'Hello '+ IntToStr(Node.AbsoluteInde
Node.Data := S;
end;
procedure TForm1.Button2Click(Sender
begin
IF TreeView1.Selected <> NIL Then
IF TreeView1.Selected.Data <> NIL
then ShowMessage ( pString(TreeView1.Selected
end;
procedure TForm1.TreeView1Deletion(S
begin
Dispose(pString(node.data)
end;
end.
Best Regards
Cesario