Hi, i want to add alle the controls from a form to a panel on another form (sort of an MDI app), the method i would like to be using doesn't seem to get all the controls, and furthermore, it seems that the controls are removed from the collection - the method is here:
For Each ctl As Control In FormObject.ControlsnewPanel.Controls.Add(ctl)
NextAnother method, which i'm using now, has to add the controls manually by getting the types of all objects, and thereafter creating them and setting the values correspondingly:
For Each objControl As Control In FormObject.Controls Dim newControl As Control = Nothing If TypeOf objControl Is Label ThennewControl =
New Label ElseIf TypeOf objControl Is TextBox ThennewControl =
New TextBox ElseIf TypeOf objControl Is DateTimePicker ThennewControl =
New DateTimePicker End If If Not newControl Is Nothing ThennewPanel.Controls.Add(newControl)
newControl.Location = objControl.Location
newControl.Size = objControl.Size
newControl.Text = objControl.Text
newControl.Show()
End If NextAny good ideas would be appreciated... Thanks in advance!

Add entire contents from a form to a panel
hedelein
iainmcc
Dmitry Lomov
I used this procedure to to move all the controls from a tabpage to a form.
Private Sub OnteoraTabControl_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DoubleClick
Dim pt As Point
Dim x As Integer
Dim tp As TabPage
pt = Me.PointToClient(Cursor.Position)
For x = 0 To Me.TabCount - 1
Dim r As Rectangle = Me.GetTabRect(x)
If r.Contains(pt) Then
intTab = x
End If
Next
tp = Me.TabPages.Item(intTab)
Dim frm As New frmFloatTab(Me)
Dim ctrl As Control
frm.Text = tp.Text
frm.Panel1.BackColor = tp.BackColor
frm.Panel1.ForeColor = tp.ForeColor
For Each ctrl In tp.Controls
ctrl.Parent = frm.Panel1
Next
If tp.ImageIndex >= 0 Then
Dim bm As Bitmap = Me.ImageList.Images(tp.ImageIndex)
frm.Icon = Icon.FromHandle(bm.GetHicon)
frm.Tag = tp.ImageIndex
End If
frm.Show()
frm.BringToFront()
Me.TabPages.Remove(tp)
End Sub