Results 1 to 3 of 3

Thread: Setting selected tabpage header text to bold.

  1. #1

    Thread Starter
    Lively Member heuyen's Avatar
    Join Date
    Jan 2005
    Posts
    64

    Talking 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.

    you can't bind me.

  2. #2
    New Member
    Join Date
    Jun 2006
    Posts
    1

    Re: Setting selected tabpage header text to bold.

    Fantastic code snippet... thanks so much.

  3. #3
    New Member
    Join Date
    Aug 2015
    Posts
    1

    Re: Setting selected tabpage header text to bold.

    Looks good, but where do you place this code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width