TabController控件测试

下载及安装参照:http://www.cnblogs.com/dragon/archive/2005/03/24/124771.html

测试:拖动标签、双击关闭标签

 '关闭按钮触发
    Private Sub TabController_ClosePressed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabController.ClosePressed
        MsgBox("ClosePressed--" & TabController.SelectedTab.Name.ToString)
    End Sub



    'Tab Drag and Drop
    Dim TabDragging As Boolean

    Private Sub TabController_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabController.MouseLeave
        If TabDragging = True Then
            'Debug.Print("stop drag")
            TabDragging = False
            Me.Cursor = Cursors.Default
        End If
    End Sub

    Private Sub TabController_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabController.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            'Debug.Print("dragging")
            TabDragging = True
            Me.Cursor = Cursors.SizeWE
        ElseIf e.Button = Windows.Forms.MouseButtons.None Then
            If TabDragging = True Then
                'Debug.Print("stop drag")
                TabDragging = False
                Me.Cursor = Cursors.Default
            End If
        End If
    End Sub

    Private Sub TabController_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabController.MouseUp
        If e.Button = Windows.Forms.MouseButtons.Left Then
            If TabDragging = True Then
                Dim sourceTab As Crownwood.Magic.Controls.TabPage = TabController.SelectedTab
                Dim targetTab As Crownwood.Magic.Controls.TabPage = TabController.TabPageFromPoint(e.Location)
                Dim targetIndex As Integer = -1

                For i = 0 To TabController.TabPages.Count - 1
                    If TabController.TabPages(i) Is targetTab Then
                        targetIndex = i
                    End If
                Next

                If sourceTab IsNot targetTab And targetIndex > -1 Then
                    TabController.TabPages.Remove(sourceTab)
                    TabController.TabPages.Insert(targetIndex, sourceTab)
                    TabController.SelectedTab = sourceTab
                End If
            End If
        ElseIf e.Button = Windows.Forms.MouseButtons.Middle Then
            If TabDragging = False Then
                '   Tabs.Action.CloseActiveTab()
            End If
        End If
    End Sub


    '双击标签触发
    Public Sub TabController_DoubleClickTab(ByVal sender As Crownwood.Magic.Controls.TabControl, ByVal page As Crownwood.Magic.Controls.TabPage) Handles TabController.DoubleClickTab
        MsgBox("DoubleClickTab--" & page.Name.ToString)
    End Sub
原文地址:https://www.cnblogs.com/LCX/p/1818628.html