New component question

Posted on 2004-08-19
Last Modified: 2010-04-05
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?

P.S. Marco Cantu's book shows how to use my new Ttreenode in the TreeView.Add function.
Question by:d32coder
  • 2
LVL 13

Accepted Solution

BlackTigerX earned 50 total points
ID: 11841126
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)
  YourNewProperty:Integer read FYourNewProperty write FYourNewProperty;

then you could add a TdsTreeNode to a TreeView by code just as you would add a TreeNode, but referencing your TdsTreeNode type instead

Author Comment

ID: 11841587
I plugged this snippet into my project...

TdsTreeNode = class(TTreeNode)
  FTag1: Integer;
  FTag2: Integer;
  Tag1: Integer read FTag1 write FTag1;
  Tag2: Integer read FTag2 write FTag2;

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

LVL 11

Expert Comment

ID: 11842048
property  Tag1: Integer read FTag1 write FTag1;
property   Tag2: Integer read FTag2 write FTag2;

LVL 13

Expert Comment

ID: 11842168
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

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 103
Delphi: how to implement a User Shortcut mapper? 1 109
Delphi...Split view - idea? 1 68
Twebbrowser add css to the header 3 25
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question