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:
private void tab_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { tabArea = tab.GetTabRect(e.Index); tabTextArea = (RectangleF)tab.GetTabRect(e.Index); StringFormat drawFormat = new StringFormat(); drawFormat.Alignment = StringAlignment.Center; SolidBrush b = new SolidBrush(Color.Black); Graphics g = e.Graphics; Pen p = new Pen(Color.White); System.Drawing.Font font; if (e.Index == tab.SelectedIndex) { font = new Font(tab.Font.FontFamily,tab.Font.Size , FontStyle.Bold, GraphicsUnit.Point); } else { font = tab.Font; g.DrawRectangle(p, tabArea); } g.DrawString(tab.TabPages[e.Index].Text, font, b, tabTextArea, drawFormat); }
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?




Does anyone kno how i can fix these problems or another way of doing this?
Reply With Quote