Para añadir a respuesta Diversión Mun Pieng 's que funciona muy bien en pestañas horizontales, si usted fuera a utilizar pestañas verticales (como yo) entonces tendría algo como esto:
private void tabControl2_DrawItem(object sender, DrawItemEventArgs e)
{
using (Brush br = new SolidBrush(tabColorDictionary[tabControl2.TabPages[e.Index]]))
{
// Color the Tab Header
e.Graphics.FillRectangle(br, e.Bounds);
// swap our height and width dimensions
var rotatedRectangle = new Rectangle(0, 0, e.Bounds.Height, e.Bounds.Width);
// Rotate
e.Graphics.ResetTransform();
e.Graphics.RotateTransform(-90);
// Translate to move the rectangle to the correct position.
e.Graphics.TranslateTransform(e.Bounds.Left, e.Bounds.Bottom, System.Drawing.Drawing2D.MatrixOrder.Append);
// Format String
var drawFormat = new System.Drawing.StringFormat();
drawFormat.Alignment = StringAlignment.Center;
drawFormat.LineAlignment = StringAlignment.Center;
// Draw Header Text
e.Graphics.DrawString(tabControl2.TabPages[e.Index].Text, e.Font, Brushes.Black, rotatedRectangle, drawFormat);
}
}
que se hagan eco el punto de que ROJO1969 hecho, si esto es en WinForms - a continuación, debe configurar DrawMode a OwnerDrawFixed.
Agradecimientos especiales a este maravilloso blog entry que describió cómo hacer una rotación de texto en un formulario.
Todavía basado en un evento. Quiero tener un método como "SetTabHeader (página TabPage, Color del color)" –
@Levisaxos, he agregado el método que requería. Pero aún requerirás el evento. –
¡Funciona como un encanto! ¡Muchas gracias! –