+ Reply to Thread
Results 1 to 5 of 5

Thread: Getting Tabs Text in Bold after Selecting that particular Tab

  1. #1
    Rama Sampige is offline VB.NET Forum Newbie Rama Sampige is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0
    Join Date
    Mar 2010
    Posts
    2
    Reputation
    0

    Default Getting Tabs Text in Bold after Selecting that particular Tab

    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

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Age
    26
    Posts
    3,897
    Reputation
    524

    Default

    Use the SelectedIndexChanged event of the TabControl, first loop through the tab pages and remove the bold, then for the SelectedTab make it bold.
    Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.


    There are 3 kinds of people in the world: Those who can count and those who can't.
    4 out of 3 people have trouble with fractions.

    Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.

  3. #3
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Age
    37
    Posts
    10,843
    Reputation
    1443

    Default

    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.)

  4. #4
    Rama Sampige is offline VB.NET Forum Newbie Rama Sampige is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0
    Join Date
    Mar 2010
    Posts
    2
    Reputation
    0

    Default

    Quote Originally Posted by JuggaloBrotha View Post
    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

  5. #5
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist JuggaloBrotha VB.NET gold medalist
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Age
    26
    Posts
    3,897
    Reputation
    524

    Default

    Here's what I have so far:
    Code:
    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).
    Currently using: VS 2005 & 2008 Pro w/sp1 & VS 2010 Ultimate on Win7 Ultimate x64.


    There are 3 kinds of people in the world: Those who can count and those who can't.
    4 out of 3 people have trouble with fractions.

    Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts