Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

New component question

OK, I'm a total novice at creating components.

I want to create a custom TTreeNode.   I really only need to add a few properties to the existing type.

In D6, I click on NEW COMPONENT and choose an ancestor class but TTreenode isn't listed, though TTreeView is (dont need that).

What method can I use to get the TTreenode code and inherit it so I can create my new TdsTreeNode?

Don
P.S. Marco Cantu's book shows how to use my new Ttreenode in the TreeView.Add function.
0
d32coder
Asked:
d32coder
  • 2
1 Solution
 
BlackTigerXCommented:
see... TreeNode is not a component, is just a class, so if you want to derive from that you have to do it from code:

something like this:

TdsTreeNode = class(TTreeNode)
private
  FYourNewProperty:Integer;
public
published
  YourNewProperty:Integer read FYourNewProperty write FYourNewProperty;
end;

then you could add a TdsTreeNode to a TreeView by code just as you would add a TreeNode, but referencing your TdsTreeNode type instead
0
 
d32coderAuthor Commented:
I plugged this snippet into my project...


TdsTreeNode = class(TTreeNode)
private
  FTag1: Integer;
  FTag2: Integer;
public
published
  Tag1: Integer read FTag1 write FTag1;
  Tag2: Integer read FTag2 write FTag2;
end;

On compile I get an error
  Published Field 'Tag1' not a class nor an interface type.
   
I wish I knew more about this.  

Don
0
 
shaneholmesCommented:
property  Tag1: Integer read FTag1 write FTag1;
property   Tag2: Integer read FTag2 write FTag2;

Shane
0
 
BlackTigerXCommented:
yes, sorry, I missed the property part

and it doesn't have to be in the published part, it can just be public
published is for components
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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