Results 1 to 3 of 3

Thread: HowTo: Select Tab Caption Bold?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188

    HowTo: Select Tab Caption Bold?

    I am tryin to set the text of the selected tab to bold but theres no property to do this so I tried to override the drawing of the tabs.

    VB Code:
    1. private void tab_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
    2. {
    3.     tabArea = tab.GetTabRect(e.Index);
    4.     tabTextArea = (RectangleF)tab.GetTabRect(e.Index);
    5.     StringFormat drawFormat = new StringFormat();
    6.     drawFormat.Alignment = StringAlignment.Center;
    7.     SolidBrush b = new SolidBrush(Color.Black);
    8.     Graphics g = e.Graphics;
    9.     Pen p = new Pen(Color.White);
    10.     System.Drawing.Font font;
    11.     if (e.Index == tab.SelectedIndex)
    12.     {
    13.         font = new Font(tab.Font.FontFamily,tab.Font.Size , FontStyle.Bold, GraphicsUnit.Point);
    14.     }
    15.     else
    16.     {
    17.         font = tab.Font;
    18.         g.DrawRectangle(p, tabArea);
    19.     }
    20.     g.DrawString(tab.TabPages[e.Index].Text, font, b, tabTextArea, drawFormat);
    21. }

    I have a few problems with this. One is it puts the text at the top of the tab instead of the middle I'm not sure how to fix that. Second it's writting the text as multiline. Third i draw the line but with pen but don't know how to keep it from appearing under the selected tab. But the bold works Does anyone kno how i can fix these problems or another way of doing this?
    Last edited by Tewl; Dec 7th, 2003 at 01:13 AM.

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