PDA

Click to See Complete Forum and Search --> : Setting selected tabpage header text to bold.


heuyen
Aug 15th, 2005, 02:30 AM
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?attachmentid=39579&stc=1

The Surgeon
Jun 28th, 2006, 09:26 AM
Fantastic code snippet... thanks so much.