SharkBait
03-27-2006, 02:34 PM
Alright I did this a while ago and here is the thread:
http://www.xtremevbtalk.com/showthread.php?t=231738&highlight=Tabcontrol
This is the code:
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
'********************************************************************* ***************
' Creates a pseudo Transparent looking set of tabs based on the colour
' that was choosen as a background
'********************************************************************* ***************
Dim iLp As Integer
Dim rect As Rectangle
Dim rect2 As Rectangle
Dim gr As Graphics = TabControl1.CreateGraphics
Dim sFormat As New StringFormat(StringFormatFlags.DirectionVertical)
'find the area not filled with tabs and color
rect = TabControl1.GetTabRect(TabControl1.TabCount - 1)
rect2 = New Rectangle((rect.X - 5), 0, (rect.Width + 5), TabControl1.Height)
'** Match empty space with background's color
gr.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(CType(51, Byte), CType(102, Byte), CType(204, Byte))), rect2)
For iLp = 0 To TabControl1.TabCount - 1
rect = TabControl1.GetTabRect(iLp)
If (iLp <> TabControl1.SelectedIndex) Then
'** Not currently used tabs
gr.FillRectangle(Brushes.Gainsboro, rect)
gr.DrawString(TabControl1.TabPages(iLp).Text, TabControl1.Font, Brushes.Gray, rect.X + 2, rect.Y + 2, sFormat)
Else
gr.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.SystemColors.Control), rect)
gr.DrawString(TabControl1.TabPages(iLp).Text, TabControl1.Font, Brushes.Black, rect.X + 2, rect.Y + 2, sFormat)
End If
Next iLp
gr = Nothing
End Sub
Now I've noticed that when a user is moving between tabs or using any other controls on the form, that there is flicker when the form redraws the leftside tabs.
Is there away around the flicker?
Also I am using the following for the text format of the TabControls
dim sFormat as new StringFormat(StringFormatFlags.DirectionVertical)
Is there a way to mirror the text? I want to be able to mirror it on the X axis and not sure how to go about that.
http://www.xtremevbtalk.com/showthread.php?t=231738&highlight=Tabcontrol
This is the code:
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
'********************************************************************* ***************
' Creates a pseudo Transparent looking set of tabs based on the colour
' that was choosen as a background
'********************************************************************* ***************
Dim iLp As Integer
Dim rect As Rectangle
Dim rect2 As Rectangle
Dim gr As Graphics = TabControl1.CreateGraphics
Dim sFormat As New StringFormat(StringFormatFlags.DirectionVertical)
'find the area not filled with tabs and color
rect = TabControl1.GetTabRect(TabControl1.TabCount - 1)
rect2 = New Rectangle((rect.X - 5), 0, (rect.Width + 5), TabControl1.Height)
'** Match empty space with background's color
gr.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(CType(51, Byte), CType(102, Byte), CType(204, Byte))), rect2)
For iLp = 0 To TabControl1.TabCount - 1
rect = TabControl1.GetTabRect(iLp)
If (iLp <> TabControl1.SelectedIndex) Then
'** Not currently used tabs
gr.FillRectangle(Brushes.Gainsboro, rect)
gr.DrawString(TabControl1.TabPages(iLp).Text, TabControl1.Font, Brushes.Gray, rect.X + 2, rect.Y + 2, sFormat)
Else
gr.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.SystemColors.Control), rect)
gr.DrawString(TabControl1.TabPages(iLp).Text, TabControl1.Font, Brushes.Black, rect.X + 2, rect.Y + 2, sFormat)
End If
Next iLp
gr = Nothing
End Sub
Now I've noticed that when a user is moving between tabs or using any other controls on the form, that there is flicker when the form redraws the leftside tabs.
Is there away around the flicker?
Also I am using the following for the text format of the TabControls
dim sFormat as new StringFormat(StringFormatFlags.DirectionVertical)
Is there a way to mirror the text? I want to be able to mirror it on the X axis and not sure how to go about that.