Hi,
My form contains a tab control and I want to be able to adjust the colors and the font color of the tabs. This must depend on certain conditions. As a first step, I want to make with owner draw tabs exactly the same as if Drawmode = normal is set. I can't find anywhere how to do this. As soon as you get started with Drawmode = OwnerdrawFixed, the tabs get ugly.
This I have found so far:
TabControlCharts.DrawItem += new DrawItemEventHandler(tabControl1_DrawItem_1);
private void tabControl1_DrawItem_1(object sender, DrawItemEventArgs e)
{
var tabControl = sender as TabControl;
var tabPage = tabControl.TabPages[e.Index];
var format = new StringFormat
{
FormatFlags = StringFormatFlags.NoWrap,
Trimming = StringTrimming.None
};
// DrawString
//using (var brush = new SolidBrush(Color.Black))
// e.Graphics.DrawString(tabPage.Text, e.Font, brush, tabControl.GetTabRect(e.Index), format);
// DrawText
var flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine;
TextRenderer.DrawText(e.Graphics, tabPage.Text, e.Font, e.Bounds, Color.Black, flags);
}
Unfortunately, the result does not resemble Drawmode = OwnerdrawFixed.
Greetings
