Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated