So I was tinkering with my tabpages and removing them with my middle click and I came across a problem:Code:Public Class Form1 Private m_MouseCoords As Point Private Sub TabControl1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseClick If e.Button = Windows.Forms.MouseButtons.Middle Then If TabControl1.TabPages.Count > 0I Then Dim TabPageIndex As Integer = -1I For Counter As Integer = 0I To TabControl1.TabPages.Count - 1I If TabControl1.GetTabRect(Counter).Contains(m_MouseCoords) Then TabPageIndex = Counter End If Next Counter If TabPageIndex > -1I Then TabControl1.TabPages.RemoveAt(TabPageIndex) If TabControl1.TabPages.Count > 0I Then TabControl1.SelectedIndex = 0I 'Selects the first one End If End If End If End Sub Private Sub TabControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseDown If e.Button = Windows.Forms.MouseButtons.Middle Then m_MouseCoords = New Point(e.X, e.Y) End Sub Private Sub TabControl1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseUp m_MouseCoords = Nothing End Sub End Class
Make a new form with this code and then make a tabcontrol with 8 tabs, run it and click tabpage8 then tabpage7 and then try to remove tabpage4; unfortunately it removes tabpage3. Any help is appreciated, thanks!


Reply With Quote
