Results 1 to 2 of 2

Thread: copy groupbox with childs from one tab to another

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    103

    copy groupbox with childs from one tab to another

    Hey, is there a way in vb.net 2005 express edition to copy a groupbox from a tab to a new tab.

    More specefiek:
    I have a button on the first tab. This button creates a new tab, and copy a groupbox from the first tab to the other. In this groupbox there are textfields, labels, buttons,...

    I should make as many tabs i want, and fill them in undepended of the other.
    That because on the firsttab there is a datagridview with persons, when i click on a person he opens a tab with al the info in of this person. If i want to create a new person, i have the click on the button new, so ik can make a new person.

    now i use this code, but when i make another tab, the groupbox isn't visible anymore.

    VB Code:
    1. Private Sub btnNewCustomer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewCustomer.Click
    2.         Dim t As New TabPage
    3.         Dim g As New GroupBox
    4.         g = Me.grpCreateCustomer
    5.         g.Visible = True
    6.  
    7.         Me.tabTabcontrol1.TabPages.Add(t)
    8.         t.Text = "new tabpage"
    9.         t.Controls.Add(g)
    10.     End Sub

    i hope you all understand it,
    greetz and thanks, freakyme
    VB.NET 2005 n00b

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: copy groupbox with childs from one tab to another

    What you should do is inherit the TabPage class and add code to create all the controls you need on a page. You then create instances of this class and add them to your TabControl instead of vanilla TabPages. Now the work to create all the controls is encapsulated within the tab page itself and you don't have to concern yourself with that when you use one. That's what OOP is all about.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width