Results 1 to 18 of 18

Thread: Tab Questions

Threaded View

  1. #11

    Thread Starter
    Member
    Join Date
    Jan 2013
    Posts
    50

    Re: Tab Questions

    Here is the full code.
    updated to prevent the user from closing the last tab.

    Code:
        Private Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim Tp As New TabPage
            Dim NewTab As New Tab
            NewTab.Show()
            NewTab.TopLevel = False
            NewTab.Dock = DockStyle.Fill
            Tp.Controls.Add(NewTab)
            TabControlBox.TabPages.Add(Tp)
        End Sub
    
        Private Sub MainWindow_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
            Dim Tp As New TabPage
            Dim NewTab As New Tab
            NewTab.Show()
            NewTab.TopLevel = False
            NewTab.Dock = DockStyle.Fill
            Tp.Controls.Add(NewTab)
            TabControlBox.TabPages.Add(Tp)
            TabControlBox.SelectedTab = Tp
        End Sub
    
        Private Sub TabControlBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControlBox.MouseDown
            If e.Button = Windows.Forms.MouseButtons.Right Then
                If TabControlBox.TabCount > 1 Then
                    If Not TabPageIndex = -1 Then
                        Dim CurrentIndex As Integer = TabControlBox.SelectedIndex
                        TabControlBox.Controls.RemoveAt(TabPageIndex)
                        If CurrentIndex < TabPageIndex Then
                            TabControlBox.SelectedIndex = CurrentIndex
                        ElseIf CurrentIndex > TabPageIndex Then
                            TabControlBox.SelectedIndex = CurrentIndex - 1
                        Else
                            If CurrentIndex < TabControlBox.TabCount Then
                                TabControlBox.SelectedIndex = CurrentIndex
                            Else
                                TabControlBox.SelectedIndex = 0
                            End If
                        End If
                    End If
                End If
            End If
        End Sub
    
    End Class
    Last edited by codenewbie; Jan 26th, 2013 at 09:03 PM.

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