Comment peut-on chan,ger les couleurs d'un tabcontrol ?

cs_abari Messages postés 89 Date d'inscription mardi 3 août 2004 Statut Membre Dernière intervention 20 février 2006 - 10 août 2004 à 20:37
TheSaib Messages postés 2367 Date d'inscription mardi 17 avril 2001 Statut Membre Dernière intervention 26 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

2 réponses

TheSaib Messages postés 2367 Date d'inscription mardi 17 avril 2001 Statut Membre Dernière intervention 26 décembre 2007 23
11 août 2004 à 02:52
Dans ton constructeur de ta form :
----------------------------

Me.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed
AddHandler Me.tabControl1.DrawItem, AddressOf Me.tabControl1_DrawItem

----------------------------

dans le corps

----------------------------

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

::|The S@ib|::
MVP C#.NET
0
TheSaib Messages postés 2367 Date d'inscription mardi 17 avril 2001 Statut Membre Dernière intervention 26 décembre 2007 23
11 août 2004 à 02:52
C'est moche mais ca marche , a toi de choisir tes couleurs

::|The S@ib|::
MVP C#.NET
0
Rejoignez-nous