tags:

views:

106

answers:

2

Hello,

I've been googling, testing, etc for a couple hours and I'm right where I started off. the vb.net tab control sucks... Does anyone have an tips or code to make it so when I select a tab the font color changes OR it just makes the tab heading text bold?

I've messed around with the draw commands and while that does work, it draws the borders/backgrounds so they are very old / outdated looking.

This is basically for a simple tab text editor I'm working on when a textbox in the control changes I can update the associated tab with either a red font or just bold it to indicate the textbox on that tab is modified.

I've definitely be open for alternative tab controls as long as they are free and come with a vb.net example :)

This is in vb.net 2008 express

A: 

Set the DrawMode of the tab control to OwnerDrawFixed and paint the tabs yourself in response to the DrawItem event.

Will A
A: 

Set the TabControl drawmode to OwnerDrawFixed then create a eventhandler to paint the tabs in response to the DrawItem event. e.g.

Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
  Dim tabctl As TabControl = DirectCast(sender, TabControl)
  Dim g As Graphics = e.Graphics
  Dim font As Font = tabctl.Font
  Dim brush As New SolidBrush(Color.Black)
  tabTextArea = RectangleF.op_Implicit(tabctl.GetTabRect(e.Index))
  If tabctl.SelectedIndex = e.Index Then
    font = New Font(font, FontStyle.Bold)
    brush = New SolidBrush(Color.Red)
  End If
  g.DrawString(tabctl.TabPages(e.Index).Text, font, brush, tabTextArea)
End Sub
fivebob
that works great but it also reskins the actual tab (makes it look like it's 1995 style) instead of the default 2005 tab style. Is there anyway to just change the text and not the actual tab?
Joe
Not easily, there is no option that I know of that only affects the text. Once the Drawmode is set to OwnerDrawFixed then the event handler is responsible for the look of the tab and I know of no way of making it use XP themes.
fivebob