views:

1589

answers:

5

On my system, the caption of a groupbox is always a dark blue colour, how do I change this?

The answer to How do you change the color of the border on a group box? shows how I can override the drawing of the caption and border, but I don't want to have to deal with Visual Styles and drawing rounded corners and the like.

A: 

In Delphi at least, the caption is just the font color, you want to make sure parentfont is false. But that may not be useful at all to you since you tagged your question .net

Peter Turner
+1  A: 

ForeColor is the property that controls the color of the text in a groupbox.

Moose
A: 

It seems I can set the caption colour by setting the ForeColor to the colour I want and setting the FlatStyle to Standard.

If the FlatStyle is System, or if it's Standard and the ForeColor isn't changed from the default, then the caption color is set to the color specified in the XP Theme.

Patrick McDonald
+1  A: 

This ought to do the trick:

public Form1()
{
  InitializeComponent();
  GroupBoxRenderer.RenderMatchingApplicationState = false;
  groupBox1.ForeColor = Color.Green;
}
Hans Passant
This is an answer to another question I have asked, if you post this answer to [http://stackoverflow.com/questions/590864/how-do-i-set-the-font-color-of-a-label-to-the-same-as-the-caption-color-of-a-grou] I'll accept it there
Patrick McDonald
Confuzzling. I updated my answer.
Hans Passant
Thanks for the update :)
Patrick McDonald
A: 

The above did not help me.
I found the solution here by adding the GroupBox.Header tag:

<GroupBox>
  <GroupBox.Header>
      <TextBlock Text="Header" Foreground="Black"/>
  </GroupBox.Header>
</GroupBox>
almhe03
Which is for WPF, not WinForms.
almhe03