Comment puis-je changer la couleur de chaque onglet?

J'ai un formulaire qui a quatre pattes sur elle, je voudrais que chaque onglet pour être d'une couleur différente. La seule chose que j'ai pu trouver sur l'internet est de savoir comment changer la couleur de l'onglet sélectionné, et le reste des onglets rester la couleur d'origine. Je n'ai pas trouvé de quoi donner à chaque onglet de sa propre couleur. Le code que j'ai actuellement est.

Private Sub TabControl1_DrawItem(sender As System.Object, e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem

        Dim g As Graphics = e.Graphics
        Dim tp As TabPage = TabControl1.TabPages(e.Index)
        Dim br As Brush
        Dim sf As New StringFormat

        Dim r As New RectangleF(e.Bounds.X, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height - 2)

        sf.Alignment = StringAlignment.Center

        Dim strTitle As String = tp.Text

        If TabControl1.SelectedIndex = e.Index Then

            'this is the background color of the tabpage header
            br = New SolidBrush(Color.LightSteelBlue) ' chnge to your choice
            g.FillRectangle(br, e.Bounds)

            'this is the foreground color of the text in the tab header
            br = New SolidBrush(Color.Black) ' change to your choice
            g.DrawString(strTitle, TabControl1.Font, br, r, sf)

        Else

            'these are the colors for the unselected tab pages 
            br = New SolidBrush(Color.Blue) ' Change this to your preference
            g.FillRectangle(br, e.Bounds)
            br = New SolidBrush(Color.Black)
            g.DrawString(strTitle, TabControl1.Font, br, r, sf)

        End If
    End Sub
Citation: ' Change this to your preference. Oui, bonne idée.

OriginalL'auteur TEC C | 2015-05-04