Heiko Posted June 29, 2003 Posted June 29, 2003 Just for the record, as I have already told the customer that there is no such builtin functionality so his wish won't come for free :) Is there a way to display the text of a tabpage (formerly known as caption) in a bold font? Setting the font property of the page will affect all controls on the page, but not its very own text/caption. Am I missing sth ? Quote .nerd
*Experts* Volte Posted June 29, 2003 *Experts* Posted June 29, 2003 You'll need to set the DrawMode property to OwnerDrawFixed and draw the text onto the tabs yourself in the DrawItem event. However, the problem with this method is that bold characters are wider than regular characters, and you can't change the widths of the tabs themselves, so bold text wouldn't fit. You could either append spaces to the Text property of each tab (which would cause the tab to resize itself to fit), or find another way to make the tabs stand out (such as using red font or something). Quote
*Experts* Volte Posted June 29, 2003 *Experts* Posted June 29, 2003 Here is a simple example I just whipped up; you'll need to add your own code to only color the ones you want or whatever. Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem Dim g As Graphics = e.Graphics Dim textX, textY As Integer Dim textSize As SizeF Dim tabText As String = TabControl1.TabPages(e.Index).Text textSize = g.MeasureString(tabText, TabControl1.Font) textX = e.Bounds.X + (e.Bounds.Width - textSize.ToSize.Width) \ 2 textY = e.Bounds.Y + (e.Bounds.Height - textSize.ToSize.Height) \ 2 g.DrawString(TabControl1.TabPages(e.Index).Text, TabControl1.Font, Brushes.Red, textX, textY) End Sub Quote
Heiko Posted June 30, 2003 Author Posted June 30, 2003 I'll give it a try (tomorrow). Thanks a lot. (Hands over one "favour" voucher) Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.