473,473 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please help - font color

How do I set the font color of the text on the actual tab
of a tab page? I have tried changing the forecolor. That
only changes the color for the text inside the tab, it
doesn't change the color of the text displayed on the
actual tab. I want to change the color of TabPage1.text,
not the other controls on the tab page
Jul 21 '05 #1
3 4487
You'll have to set the TabControls DrawMode property to OwnerDrawFixed and
draw the text in the TabControls DrawItem procedure.

VB.Net example:

Private Sub TabControl1_DrawItem(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) _
Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
e.Font, Brushes.Red, r,
sf)
Else
e.Graphics.DrawString(TabControl1.TabPages(e.Index ).Text, _
e.Font,
Brushes.Blue, r, sf)
End If

End Sub
"Keni" <ke********@bcbsmt.com> wrote in message
news:0f****************************@phx.gbl...
How do I set the font color of the text on the actual tab
of a tab page? I have tried changing the forecolor. That
only changes the color for the text inside the tab, it
doesn't change the color of the text displayed on the
actual tab. I want to change the color of TabPage1.text,
not the other controls on the tab page

Jul 21 '05 #2
Thank you so much!!! It works great!! You are my hero!
-----Original Message-----
You'll have to set the TabControls DrawMode property to OwnerDrawFixed anddraw the text in the TabControls DrawItem procedure.

VB.Net example:

Private Sub TabControl1_DrawItem(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) _ Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _ e.Font, Brushes.Red, r,sf)
Else
e.Graphics.DrawString(TabControl1.TabPages (e.Index).Text, _ e.Font,Brushes.Blue, r, sf)
End If

End Sub
"Keni" <ke********@bcbsmt.com> wrote in message
news:0f****************************@phx.gbl...
How do I set the font color of the text on the actual tab of a tab page? I have tried changing the forecolor. That only changes the color for the text inside the tab, it
doesn't change the color of the text displayed on the
actual tab. I want to change the color of TabPage1.text, not the other controls on the tab page

.

Jul 21 '05 #3
No problem, Glad to help.
Note however, that this method requires quite a bit of work if Windows XP
Visual Styles are in use since you'll also have to pinvoke the various
uxtheme.dll functions to extract the TabItem bitmaps.

"Keni" <ke********@bcbsmt.com> wrote in message
news:04****************************@phx.gbl...
Thank you so much!!! It works great!! You are my hero!
-----Original Message-----
You'll have to set the TabControls DrawMode property to

OwnerDrawFixed and
draw the text in the TabControls DrawItem procedure.

VB.Net example:

Private Sub TabControl1_DrawItem(ByVal sender As Object, _
ByVal e As

System.Windows.Forms.DrawItemEventArgs) _
Handles TabControl1.DrawItem

Dim r As RectangleF = RectangleF.op_Implicit(e.Bounds)
Dim ItemBrush As New SolidBrush(TabControl1.BackColor)
Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

If CBool(e.State And DrawItemState.Selected) Then
e.Graphics.FillRectangle(ItemBrush, e.Bounds)
e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _

e.Font, Brushes.Red, r,
sf)
Else
e.Graphics.DrawString(TabControl1.TabPages

(e.Index).Text, _

e.Font,
Brushes.Blue, r, sf)
End If

End Sub
"Keni" <ke********@bcbsmt.com> wrote in message
news:0f****************************@phx.gbl...
How do I set the font color of the text on the actual tab of a tab page? I have tried changing the forecolor. That only changes the color for the text inside the tab, it
doesn't change the color of the text displayed on the
actual tab. I want to change the color of TabPage1.text, not the other controls on the tab page

.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
4
by: anatushi | last post by:
Hi, im looking for help on how to add a text fader to my website, usually i'm working with css but in this case i need to add java script to make it work, that wasn't the problem but somehow it...
0
by: PayPal Service | last post by:
<div id=3D"AOLMsgPart_0_cfc2d77d-bb8d-499a-832c-efe0f664221a"> <html> <head> <title>Dear PayPal User</title> </head>
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your...
5
by: loveshack | last post by:
Can anyone help me please (i am quite a novice, but having fun learning). Im not sure if this is an ASP problem, a javascript problem or a browser problem. Firstly, everything i have written...
12
by: iahamed | last post by:
Hi Everyone, I got two parts of my advance search to work, I am running out of Logic to connect the third. My mind is in swing! Pleaseeeeeeeee Help me. I have 3 Fiels to search, the First two...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.