Comment peut-on chan,ger les couleurs d'un tabcontrol ?
cs_abari
Messages postés89Date d'inscriptionmardi 3 août 2004StatutMembreDernière intervention20 février 2006
-
10 août 2004 à 20:37
TheSaib
Messages postés2367Date d'inscriptionmardi 17 avril 2001StatutMembreDernière intervention26 décembre 2007
-
11 août 2004 à 02:52
Je sais modifier les couleurs des tabpage :
Me.TabControl1.TabPages.Item(0).BackColor = System.Drawing.Color.Green)
... mais ce que je veux c'est de modifier la couleur des onglets et si il est possible je veux changer aussi le fond
de la barre où se trouvent les onglets.
Merci de vos suggestions
Private Sub tabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
Dim f As Font
Dim backBrush As Brush
Dim foreBrush As Brush
If e.Index = Me.tabControl1.SelectedIndex Then
f = New Font(e.Font, FontStyle.Italic Or FontStyle.Bold)
backBrush = New System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Blue, Color.Red, System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal)
foreBrush = Brushes.PowderBlue
Else
f = e.Font
backBrush = New SolidBrush(e.BackColor)
foreBrush = New SolidBrush(e.ForeColor)
End If
Dim tabName As String = Me.tabControl1.TabPages(e.Index).Text
Dim sf As New StringFormat()
sf.Alignment = StringAlignment.Center
e.Graphics.FillRectangle(backBrush, e.Bounds)
Dim r As RectangleF = New RectangleF(e.Bounds.X, e.Bounds.Y + 4, e.Bounds.Width, e.Bounds.Height - 4)
e.Graphics.DrawString(tabName, f, foreBrush, r, sf)
sf.Dispose()
If e.Index = Me.tabControl1.SelectedIndex Then
f.Dispose()
backBrush.Dispose()
Else
backBrush.Dispose()
foreBrush.Dispose()
End If
End Sub 'tabControl1_DrawItem