Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Setting Treeview to another Treeview

Setting Treeview to another Treeview

Scheduled Pinned Locked Moved C#
debugging
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    smarttom99
    wrote on last edited by
    #1

    I have a treeview and I want to set another treeview to that treeview when I set TV1 = TV2 and do a breakpoint TV1 looks to have all the nodes, but it doesn't display. Does anyone know what I might have wrong. Thanks.

    N 1 Reply Last reply
    0
    • S smarttom99

      I have a treeview and I want to set another treeview to that treeview when I set TV1 = TV2 and do a breakpoint TV1 looks to have all the nodes, but it doesn't display. Does anyone know what I might have wrong. Thanks.

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello TreeViews are reference types. That means that TV1 = TV2 will only copy the reference to the same object, but at the end they are still one thing. If you change anything in TV1, it will be also changed in TV2. To copy the whole NodesCollection of one TreeView to another

      TreeNode[] TV1Nodes = new TreeNode[TV1.Nodes.Count];
      TV1.Nodes.CopyTo(TV1Nodes, 0);
      foreach(TreeNode Tn in TV1Nodes)
      TV2.Nodes.Add(Tn);

      Regards:rose:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups