0

Alguém sabe como mudar a cor do titulo ta TabPage em C#? Não a cor do texto da página inteira, só a do titulo da página (da Tab).

1
  • Qual é a tecnologia de interface gráfica (GUI)?
    – Tony
    17/09/2014 às 11:43

1 Resposta 1

0

No Evento abaixo, incluir o seguinte codigo.

private void TAB_DrawItem(object sender, DrawItemEventArgs e)
{
    TabPage CurrentTab = TAB.TabPages[e.Index];
    Rectangle ItemRect = TAB.GetTabRect(e.Index);
    SolidBrush FillBrush = new SolidBrush(Color.White);
    SolidBrush TextBrush = new SolidBrush(Color.Black);
    StringFormat sf = new StringFormat();
    sf.Alignment = StringAlignment.Center;
    sf.LineAlignment = StringAlignment.Center;

    //If we are currently painting the Selected TabItem we'll
    //change the brush colors and inflate the rectangle.
    if (System.Convert.ToBoolean(e.State & DrawItemState.Selected))
    {
        FillBrush.Color = Color.Red;
        TextBrush.Color = Color.White;
        ItemRect.Inflate(2, 2);
    }

    //Set up rotation for left and right aligned tabs
    if (TAB.Alignment == TabAlignment.Left || TAB.Alignment == TabAlignment.Right)
    {
        float RotateAngle = 90;
        if (TAB.Alignment == TabAlignment.Left)
            RotateAngle = 270;
        PointF cp = new PointF(ItemRect.Left + (ItemRect.Width / 2), ItemRect.Top + (ItemRect.Height / 2));
        e.Graphics.TranslateTransform(cp.X, cp.Y);
        e.Graphics.RotateTransform(RotateAngle);
        ItemRect = new Rectangle(-(ItemRect.Height / 2), -(ItemRect.Width / 2), ItemRect.Height, ItemRect.Width);
    }

    //Next we'll paint the TabItem with our Fill Brush
    e.Graphics.FillRectangle(FillBrush, ItemRect);

    //Now draw the text.
    e.Graphics.DrawString(CurrentTab.Text, e.Font, TextBrush, (RectangleF)ItemRect, sf);


    //Reset any Graphics rotation
    e.Graphics.ResetTransform();

    //Finally, we should Dispose of our brushes.
    FillBrush.Dispose();
    TextBrush.Dispose();
}

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .