Private Sub TabControl1_MouseUp(ByVal sender As Object _ , ByVal e As System.Windows.Forms.MouseEventArgs _ ) Handles TabControl1.MouseUp Dim nTabIndexAs Integer 'Detect on which tab the user has clicked For nTabIndex= 0 To TabControl1.TabPages.Count - 1 If e.X >= TabControl1.GetTabRect(nTabIndex).X _ AndAlso e.X <= TabControl1.GetTabRect(nTabIndex).Width _ + TabControl1.GetTabRect(nTabIndex).X _ Then Exit For End If Next If e.Button = Windows.Forms.MouseButtons.Middle Then TabControl1.TabPages.RemoveAt(nTabIndex) End If End Sub
Labels: .NET Framework, .NET Framework 2.0, Close TabPage, middle click