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,
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.
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.
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.)
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly
Here's what I have so far:Up next: OwnerDraw the control, as John's already pointed out, so the TabPage's Font actually gets used (so the bold shows up).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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks