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. Can a control have multi parents?

Can a control have multi parents?

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
4 Posts 3 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.
  • D Offline
    D Offline
    Duong Tien Nam
    wrote on last edited by
    #1

    Hi every body, I have to forms, each form has a tree that is exactly the same with the other, the best way is to use one tree control for both form, but I realize that when you add a control to another parent, the former parent will remove it from it's Controls' list. You have any idea to solve my problem? Thanks a lot! Regards.

    L D 2 Replies Last reply
    0
    • D Duong Tien Nam

      Hi every body, I have to forms, each form has a tree that is exactly the same with the other, the best way is to use one tree control for both form, but I realize that when you add a control to another parent, the former parent will remove it from it's Controls' list. You have any idea to solve my problem? Thanks a lot! Regards.

      L Offline
      L Offline
      Luc 648011
      wrote on last edited by
      #2

      A Control can only be visible once, it has at most one Parent, and resides in at most one Controls collection. So it is fine to move a Control around in some cases: - from one tab page to the next when these pages belong to the same TabControl (hence at most one of them is showing), - from one modal dialog to the next (at most one of them showing again) but you can't reuse a Control in general. You would have to have two Controls, and use code to keep them synchronized. :)

      modified on Saturday, April 11, 2009 1:25 PM

      D 1 Reply Last reply
      0
      • D Duong Tien Nam

        Hi every body, I have to forms, each form has a tree that is exactly the same with the other, the best way is to use one tree control for both form, but I realize that when you add a control to another parent, the former parent will remove it from it's Controls' list. You have any idea to solve my problem? Thanks a lot! Regards.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        A control can have only one parent. There's nothing stopping you form removing the control from one parent's Controls collection and adding it to another though.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        1 Reply Last reply
        0
        • L Luc 648011

          A Control can only be visible once, it has at most one Parent, and resides in at most one Controls collection. So it is fine to move a Control around in some cases: - from one tab page to the next when these pages belong to the same TabControl (hence at most one of them is showing), - from one modal dialog to the next (at most one of them showing again) but you can't reuse a Control in general. You would have to have two Controls, and use code to keep them synchronized. :)

          modified on Saturday, April 11, 2009 1:25 PM

          D Offline
          D Offline
          Duong Tien Nam
          wrote on last edited by
          #4

          Pity :( It's a MDI application, user can even move the MDI forms around and align them parallely to work together. Now I have many troubles synchronize them. Anyway, thanks for you answers, I can use them in some other cases.

          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