Results 1 to 5 of 5

Thread: TabControl Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108

    Unhappy TabControl Problem

    i have a problem to remove a tab page

    example i have 3 or more than 3 tabpage

    how can i remove the tabpage that i have selected ???

    i got 3 tabpage name call a,b and c

    if i at the tabpage b and when i click the delete button
    the tabpage b will be remove

    thanx for helping me again

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    This works for me:
    VB Code:
    1. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    2.         Dim t As TabPage
    3.         For Each t In Me.TabControl1.TabPages
    4.             If Me.TabControl1.SelectedTab.Name = t.Name Then Me.TabControl1.TabPages.Remove(t)
    5.             Exit For
    6.         Next
    7.     End Sub

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or using one line of code
    VB Code:
    1. Me.TabControl1.Controls.Remove(Me.TabControl1.SelectedTab)

  4. #4
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Much better solution, been working with collections like a mad man for the past few days, just stuck in that "loop"

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    108
    thanx ~
    the code is working

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