Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

GroupBox and/or Tab Control Font Colours

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew McNab - 10 Feb 2007 08:01 GMT
From all the control properties I have seen, there isn't a way of changing
the font colour for GroupBox titles and TabPage titles. Is there any way
around this? Would it be possible to clone the control and modify it or are
the colours inherited from the OS colour schemes? I have no idea how to make
custom controls by the way. Any tips would be great. Thanks :o)
Mick Doherty - 10 Feb 2007 09:19 GMT
When using Visual Styles the forecolor is set by the current Theme.

It is possible to Inherit the controls and draw them as you wish. Groupbox
is relatively simple to modify, but TabControl is much more complex.

If you're not averse to using free third party controls, then you can
download TabControlEx from my site. The dll also includes
GroupBoxEx(supports Transparent Background) which I have just modified to
allow a custom forecolor with VisualStyles.
http://www.dotnetrix.co.uk/controls.html

If you want to attempt to create a custom TabControl then you will find
several tips on my site:
http://www.dotnetrix.co.uk/tabcontrols.html

...and some nice examples on codeproject:
http://www.codeproject.com/cs/miscctrl/flattabcontrol.asp
http://www.codeproject.com/dotnet/CustomTabControl.asp

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> From all the control properties I have seen, there isn't a way of changing
> the font colour for GroupBox titles and TabPage titles. Is there any way
[quoted text clipped - 3 lines]
> make
> custom controls by the way. Any tips would be great. Thanks :o)
Andrew McNab - 11 Feb 2007 13:03 GMT
Thanks for the reply Mick. I'm not fussed about the Tab Control font. The
GroupBox is essential however. I had a bit of a surf for info on either how
to modify the groupbox title font colour or overriding the inheritance. All I
found were other controls that other people had created. I'd rather not use
3rd party controls.

In order to change the font colour, am I able to do it through the Marshal
using unmanaged code (rather not go down that path) or will I have to clone
the control and make my own 3rd party control with an altered font colour? I
read a few things about intercepting the renderer using the drawing event for
controls and changing the colour of the "brush" the engine is using while it
draws the group box border and title text. Is that the most "thread" safe way
to do it? Links to documentation about most commonly used techniques would be
fantastic.

Thanks again Mick
Mick Doherty - 11 Feb 2007 20:09 GMT
There's a quick and simple way to get the desired effect:

Set the Groupbox.Text to ""
Place a label over the groupbox where the caption would have been.

You could also just Paint over the top of the existing caption in the
groupbox's Paint() method.

This all assumes that you are using VS2002\2003, as VS2005 allows Visual
Styles with FlatStyle.Standard. The reason VS2003 does not allow a custom
caption color is that the control must use FlatStyle.System in order to be
painted with Visual Styles and, therefore, uses System Colors for the
caption. I should have mentioned this earlier.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> Thanks for the reply Mick. I'm not fussed about the Tab Control font. The
> GroupBox is essential however. I had a bit of a surf for info on either
[quoted text clipped - 21 lines]
>
> Thanks again Mick
Andrew McNab - 11 Feb 2007 22:23 GMT
Yes I am using .Net 2005. I'll have a look into the Paint() method. I
suspected that the caption was inheriting System Colours. Thanks again :o)
Mick Doherty - 12 Feb 2007 10:55 GMT
> Yes I am using .Net 2005. I'll have a look into the Paint() method. I
> suspected that the caption was inheriting System Colours. Thanks again :o)

In .net 2005, you should just set FlatStyle.Standard. The Groupbox should
then paint the caption using whatever ForeColor you set.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

Andrew McNab - 13 Feb 2007 23:31 GMT
I found the "problem". I was creating a TabControl just with the design
interface. I was messing around with properties to see what I could get the
control to look like before writing code that dynamically creates controls
during runtime. I set the fore colour of the TabPage to white. When I created
a group box within that tab page, it inherited the fore colour of the parent
but the caption text was still blue. I guess I was so tired when I was
messing around with it that I didn't try to change the fore colour of the
group box. Once you change it in the properties window, the text changes
colour. Seems the inheritance doesn't work. Thanks again :o)
Jeff Glatt - 14 Feb 2007 20:11 GMT
Could try XTabControl from http://www.springsys.com

-j

17DD4827BB2A@microsoft.com...
> From all the control properties I have seen, there isn't a way of changing
> the font colour for GroupBox titles and TabPage titles. Is there any way
[quoted text clipped - 3 lines]
> make
> custom controls by the way. Any tips would be great. Thanks :o)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.