Visual Styles only applies to XP and above. In this case you'll need to
ownerdraw the Tabs.
Here's a basic example for top or bottom aligned tabs with no Image, that
allows you to include the full text at designtime.
(assumes tabControl is named tabControl1).
\\\
private Hashtable multiLineTabs = new Hashtable();
private bool multiLine;
private void Form1_Load(object sender, System.EventArgs e)
{
foreach(TabPage tab in this.tabControl1.TabPages)
{
int newLineIndex = tab.Text.IndexOf(@"\n");
if (newLineIndex !=- 1)
{
if (!multiLine)
{
multiLine = true;
tabControl1.Padding = new Point(6, tabControl1.Font.Height);
}
multiLineTabs.Add(tab,tab.Text.Remove(0,newLineInd ex + 2));
tab.Text = tab.Text.Substring(0,newLineIndex);
}
}
}
private void tabControl1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
{
TabControl tabControl = (TabControl)sender;
TabPage currentTab = tabControl.TabPages[e.Index];
Graphics g = e.Graphics;
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
string tabText = currentTab.Text;
RectangleF tabRect = (RectangleF)e.Bounds;
RectangleF textRect = tabRect;
if (e.Index == tabControl.SelectedIndex)
{
tabRect.Inflate(1,1);
}
g.Clip = new Region(tabRect);
g.Clear(Control.DefaultBackColor);
g.ResetClip();
if (multiLine)
{
if (multiLineTabs.Contains(currentTab))
{
tabText += "\n" + (string)multiLineTabs[currentTab];
}
}
g.DrawString(tabText,e.Font,SystemBrushes.ControlT ext,textRect,sf);
}
///
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html