Question Getting Tabs Text in Bold after Selecting that particular Tab

Rama Sampige

New member
Joined
Mar 19, 2010
Messages
2
Programming Experience
1-3
Hi,

We have an application, which ahs 3 tabs on the main page. The need is that on selecting any one Tab, that particular Tab should appear in "BOLD", apart from the other Two Tabs in the Regular Font. Please help how to get this.

Thanks and regards
Rama
 
Use the SelectedIndexChanged event of the TabControl, first loop through the tab pages and remove the bold, then for the SelectedTab make it bold.
 
I don't there is any way around this to achieve that: TabControl.DrawItem Event (System.Windows.Forms)
Simply setting TabPage.Font would be ideal, but it currently does not have that effect. (take it we're talking about the TabControl tabs here, and not the tabpages.)
 
Use the SelectedIndexChanged event of the TabControl, first loop through the tab pages and remove the bold, then for the SelectedTab make it bold.

Hi Juggalo,

I am very new to .NET. You can Think I am a Zero. So please give me the steps in more detail.. Thanks a lot for your immediate response.

Bye for now

Regards
Rama
 
Here's what I have so far:
VB.NET:
Public Class Form1

    Private m_RegFont, m_BoldFont As Font

    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        For Each TP As TabPage In TabControl1.TabPages
            TP.Font = m_RegFont
        Next
        TabControl1.SelectedTab.Font = m_BoldFont
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        m_RegFont.Dispose()
        m_BoldFont.Dispose()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        m_RegFont = TabPage1.Font
        m_BoldFont = New Font(TabPage1.Font, FontStyle.Bold)
    End Sub
End Class
Up next: OwnerDraw the control, as John's already pointed out, so the TabPage's Font actually gets used (so the bold shows up).
 
Back
Top