Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:15:44+00:00 2026-05-27T00:15:44+00:00

Coming from Win32, I am having bit of an issue or a problem trying

  • 0

Coming from Win32, I am having bit of an issue or a problem trying to work with treeview for .NET. I have searched online, msdn library and stackoverflow and none seem to help me.

Could someone, please, show me how you can use Treeview to create node, create childnode, set data or object, retrieve object, check its level, etc…

Example code would be greatly appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:15:45+00:00Added an answer on May 27, 2026 at 12:15 am

    1) Create a root Node

    use the Nodes.Add method

    treeView1.Nodes.Add('A Node');
    

    2) Create a Child Node, get the instance to the parent node and uses the Nodes.Add

    Node.Nodes.Add('A Child Node');
    

    3) To store an object in anode use the Tag property of the Node

    Node.Tag:=MyObj;
    

    4) To Retrieve the object use the tag property and cast the value.

    MyObj2:= TMyObject(Node.Tag);
    

    5) to get the level, chek the Level property of the node.

    Check this simple code :

    Var
      Node     : TreeNode;  
      MyObj    : TMyObject; 
      MyObj2   : TMyObject; 
    begin
      Node:=treeView1.Nodes.Add('A Node'); //add a root node 
      Node.Text:= String.Format('{0} in level {1}',Node.Text,Node.Level);
    
        Node.Nodes.Add('A Child Node');
        Node.Nodes.Add('Another Child Node');
      Node:=treeView1.Nodes.Add('Another Node');
    
      MyObj:=New TMyObject;
      MyObj.Foo:='Hello';
      Node.Tag:=MyObj;//set the object
    
    
    
      MyObj2:= TMyObject(Node.Tag); //get the assigned object
      MessageBox.Show(MyObj2.Foo);
    
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from web development I have been trying to get familiar with compiled programming,
coming from the Ocaml community, I'm trying to learn a bit of Haskell. The
Coming from a Perl background, I have to say I prefer cpan Foo::Bar to
I have recently downloaded the FFmpeg-PHP extension (extracted from ffmpeg-php53-win32-vc9-all.zip) for PHP and I
Coming from the Java world, in which there are no typedefs, I have a
Coming from a background in Google Mock, I'm surprised this doesn't work, unless I'm
Coming from a different ETL tool, I'm trying to figure out how to get
I'm finding myself doing more C/C++ code against Win32 lately, and coming from a
coming from .Net world, just want to know what is the corresponding collection to
Coming from .NET, I'm used to Ninject, that's a small simple ioc-container. Is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.