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

  • SEARCH
  • Home
  • 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 1080053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:58:02+00:00 2026-05-16T21:58:02+00:00

I have a class, let’s call MyClass. In this class, I have a TreeView

  • 0

I have a class, let’s call MyClass.
In this class, I have a TreeView property let’s call myTreeView
In my code, I populate the Nodes of this TreeView so I can use it later on.
Then, when it’s time to actualy use it, I haven’t been able to take all the nodes from myClass and put them in a Tree View Control on my form.

I’ve tried two things:

1.

aTreeView=MyClass.myTreeView

which simply returns nothing (TreeView is empty)

2.

    For Each newNode As TreeNode In MyClass.myTreeView.Nodes
        aTreeView.Nodes.Add(newNode)
    Next

I get the same result here… an empty TreeView

The weird thing is that when debugging, the TreeView in MyClass is well populated with the proper values and in the loop, newNode isn’t empty, there’s actually something but for some reason it’s not showing anything.

Any help would be appreciated,

Thanks

  • 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-16T21:58:03+00:00Added an answer on May 16, 2026 at 9:58 pm

    The first snippet cannot work because aTreeView is a reference to the TreeView that is stored in the form’s Controls collection. The assignment just changes the reference, it doesn’t change the actual TreeView that the user is looking at.

    The second snippet is flawed because a TreeNode has an owner. The TreeView. The code will empty the TreeView in your class. The moved nodes might not be visible because you used the wrong reference, possible the wrong form instance. Be sure to use the one that the user is looking at. You need to use the TreeNode.Clone() method to create a copy of the node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Visual Studio 2008 (C++) I have a class destructor (Let's call this class
Greetings, I have a class (let's call it Car) that has a property of
I have created a separate class (let's call it class2.cs for example) and want
I have a non-Activity class (let's call it NonActivity) that needs to post a
I currently have a need for a custom ListViewItem class - let's call it
I suppose that this is an interesting code example. We have a class --
Let's say I have: class myClass std::list<myClass> myList where myClass does not define the
i have a class let's call it cell, .cms-block .cell{ width:520px; float:left;} .cms-block.wide .cell{width:
Not sure how to implement this scenario: I have a base class let's say
I got a class let's call it Blah. I use ObjectDataSource to get the

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.