Try
Dim mytabrect As New Rectangle
mytabrect = Me.TabControl1.GetTabRect(e.Index)
e.Graphics.DrawString(TabControl1.TabPages(e.Index).Text, Me.Font, SystemBrushes.ControlText, mytabrect.X + 5, mytabrect.Y + 5)
Dim p As New Pen(Brushes.White)
mytabrect.Offset(mytabrect.Width - 15, 2)
mytabrect.Width = 12
mytabrect.Height = 12
e.Graphics.DrawRectangle(p, mytabrect)
Dim objpen As New Pen(Brushes.Black)
Dim P1 As New Point(mytabrect.X + 3, mytabrect.Y + 3)
Dim p2 As New Point(mytabrect.X + mytabrect.Width - 3, mytabrect.Y + mytabrect.Height - 3)
e.Graphics.DrawLine(objpen, P1, p2)
Dim p3 As New Point(mytabrect.X + 3, mytabrect.Y + mytabrect.Height - 3)
Dim p4 As New Point(mytabrect.X + mytabrect.Width - 3, mytabrect.Y + 3)
e.Graphics.DrawLine(objpen, p3, p4)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
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.Left Then
Dim x = e.X, y = e.Y
Dim MyTabRect As New Rectangle
MyTabRect = TabControl1.GetTabRect(TabControl1.SelectedIndex)
MyTabRect.Offset(MyTabRect.Width - 15, 2)
MyTabRect.Width = 12
MyTabRect.Height = 12
If x >= MyTabRect.X And x < MyTabRect.Right And y > MyTabRect.Y And y < MyTabRect.Height Then
TabControl1.TabPages.Remove(TabControl1.SelectedTab)
End If
End If
End Sub