I have been
searching and
having no
luck...So
anyway, what I
need is a way
to copy tab1's
controls or
items (like
textboxes,datagridview etc) and
then have them
pasted into a
new tab.
This would be
done through a
"New Tab"
button. When
that button is
pressed, a new
tab will open up
and it should
have all the
same items
that tab1 has.
thanks for any
help...

You can try something like this:

Private Sub AddControls(ByVal lstControls As List(Of Control), ByVal tpgDestination As TabPage)
    Try
        If IsNothing(lstControls) = False Then
            For i = 0 To lstControls.Count - 1
                tpgDestination.Controls.Add(lstControls(i))
            Next
        End If
    Catch ex As Exception
        MsgBox("There was a problem adding the controls!" & vbCrLf & ex.Message & vbCrLf & ex.StackTrace.ToString)
    End Try
End Sub

Private Function Retreive_Controls(ByVal tpg As TabPage) As List(Of Control)
    Try
        Dim lstCtrl As New List(Of Control)

        For Each c As Control In tpg.Controls
            lstCtrl.Add(c)
        Next

        Return lstCtrl
    Catch ex As Exception
        MsgBox("There was a problem building the list of controls!" & vbCrLf & ex.Message & vbCrLf & ex.StackTrace.ToString)
        Return Nothing
    End Try
End Function

Then call it like:

AddControls(Retreive_Controls(TabPage1),TabPage2)

This will copy everything on TabPage1 and 'paste' it to TabPage2.
All Properties will be identical.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.