Setting selected tabpage header text to bold.
Code:
tabControl1.DrawMode=TabDrawMode.OwnerDrawFixed;
tabControl1.Padding=new Point(15,5);
private void tabcontrol1_drawitem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
TabPage currentab=tabControl1.TabPages[e.Index];
SolidBrush textbrush=new SolidBrush(Color.Black);
Rectangle itemrect=tabControl1.GetTabRect(e.Index);
StringFormat sf=new StringFormat();
sf.Alignment=StringAlignment.Center;
sf.LineAlignment=StringAlignment.Center;
if(Convert.ToBoolean(e.State & DrawItemState.Selected))
{
Font f=new Font(tabControl1.Font.Name,tabControl1.Font.Size,FontStyle.Bold);
e.Graphics.DrawString(currentab.Text,f,textbrush,itemrect,sf);
}
else e.Graphics.DrawString(currentab.Text,e.Font,textbrush,itemrect,sf);
textbrush.Dispose();
}
Love to hear any comments.:)
http://vbforums.com/attachment.php?a...id=39579&stc=1
Re: Setting selected tabpage header text to bold.
Fantastic code snippet... thanks so much.
Re: Setting selected tabpage header text to bold.
Looks good, but where do you place this code?