473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 4483
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.