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. Visual Basic
  4. Rise! (those controls) - vb.net 2003

Rise! (those controls) - vb.net 2003

Scheduled Pinned Locked Moved Visual Basic
helpcsharpquestion
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.
  • O Offline
    O Offline
    omega23
    wrote on last edited by
    #1

    I had the idea to copy the controls of a panel to a new Form. It works if I use the copyTo method of the control collection of the panel. The problem is, the controls aren't copied, there moved!? :confused: Is this a bug or ...? Anyone an idea? Test it yourself. On a simple Windows Form with a panel1, a button1 and a textbox1: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' rise! Dim form2 As New Form Dim c(Panel1.Controls.Count - 1) As Control Panel1.Controls.CopyTo(c, 0) form2.Controls.AddRange(c) form2.Size = Panel1.Size form2.Show() End Sub As you will see, the controls are moved to the new form2, instead of copied there.

    J 1 Reply Last reply
    0
    • O omega23

      I had the idea to copy the controls of a panel to a new Form. It works if I use the copyTo method of the control collection of the panel. The problem is, the controls aren't copied, there moved!? :confused: Is this a bug or ...? Anyone an idea? Test it yourself. On a simple Windows Form with a panel1, a button1 and a textbox1: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' rise! Dim form2 As New Form Dim c(Panel1.Controls.Count - 1) As Control Panel1.Controls.CopyTo(c, 0) form2.Controls.AddRange(c) form2.Size = Panel1.Size form2.Show() End Sub As you will see, the controls are moved to the new form2, instead of copied there.

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      That's because you're only copying the references to the controls, not the actual controls.

      "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
      "You must be the change you wish to see in the world." - Mahatma Gandhi

      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