Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleReparent a control in VB .NET
Keywordsreparent, set parent, parent
CategoriesVB.NET, Software Engineering
 
Simply set the control's Parent property to its new parent.

Note that the control may end up on the bottom of the new parent's stacking order so you may want to call its BringToFront method to pop it to the top.

 
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    If Button1.Parent Is GroupBox1 Then
        Button1.Parent = Me
    Else
        Button1.Parent = GroupBox1
    End If
    Button1.BringToFront()
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated