Advertisement
Dev

Custom Tab Control By Naywyn [VB]

Dev
May 2nd, 2017
38,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #UDT
  2. #UltimateDevTeam
  3.  
  4.  
  5. ' Minimal Tabcontrol.
  6. ' Made by Naywyn.
  7.  
  8. Public Class cTabControl
  9. Inherits TabControl
  10.  
  11. Private G As Graphics
  12. Private Rect As Rectangle
  13.  
  14. Sub New()
  15. DoubleBuffered = True
  16. SizeMode = TabSizeMode.Fixed
  17. ItemSize = New Size(30, 170)
  18. Alignment = TabAlignment.Left
  19. SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer, True)
  20. End Sub
  21.  
  22. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  23.  
  24. G = e.Graphics
  25.  
  26. G.Clear(Color.White)
  27.  
  28. Using Right As New Pen(Color.FromArgb(211, 223, 229))
  29. G.DrawLine(Right, ItemSize.Height + 3, 4, ItemSize.Height + 3, Height)
  30. End Using
  31.  
  32. For T As Integer = 0 To TabPages.Count - 1
  33.  
  34. Rect = GetTabRect(T)
  35.  
  36. If SelectedIndex = T Then
  37.  
  38. Using TextBrush As New SolidBrush(Color.FromArgb(32, 32, 32)), TextFont As New Font("Verdana", 10)
  39. G.DrawString(TabPages(T).Text, TextFont, TextBrush, New Point(Rect.X + 45, Rect.Y + 7))
  40. End Using
  41.  
  42. Else
  43.  
  44. Using TextBrush As New SolidBrush(Color.FromArgb(129, 129, 129)), TextFont As New Font("Verdana", 10)
  45. G.DrawString(TabPages(T).Text, TextFont, TextBrush, New Point(Rect.X + 45, Rect.Y + 7))
  46. End Using
  47.  
  48. End If
  49.  
  50. If Not IsNothing(ImageList) Then
  51. If Not TabPages(T).ImageIndex < 0 Then
  52. G.DrawImage(ImageList.Images(TabPages(T).ImageIndex), New Rectangle(Rect.X + 20, Rect.Y + 7, 16, 16))
  53. End If
  54. End If
  55.  
  56. Next
  57.  
  58. MyBase.OnPaint(e)
  59. End Sub
  60.  
  61. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement