How to set GroupBox header color

On my system, the group box header is always dark blue, how do I change this?

Answer to How to change the border color in a group box? shows how I can redefine the drawing of the label and the border, but I do not need to deal with visual styles and draw rounded corners, etc.

+4
source share
6 answers

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

+4
source

This should do the trick:

public Form1() { InitializeComponent(); GroupBoxRenderer.RenderMatchingApplicationState = false; groupBox1.ForeColor = Color.Green; } 
+3
source

It seems I can set the subtitle color by setting ForeColor to the color I want and setting FlatStyle to standard.

If FlatStyle is a System, or if Standard and ForeColor are not changed by default, then the header color will be set to the color specified in the XP theme.

+1
source

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

 <GroupBox> <GroupBox.Header> <TextBlock Text="Header" Foreground="Black"/> </GroupBox.Header> </GroupBox> 
+1
source

In Delphi, at least the title is just the font color, you want to make sure that the parentfont is false. But this may be useless to you as you have noted your .net question

0
source

Customization

 groupBox1.ForeColor 

changes forecolor of other controls, such as buttons, shortcuts, etc., located inside the group box, which in most cases is undesirable if you only need to change the text color of the group field. A simple workaround would be

  private void button1_Click(object sender, EventArgs e) { List<Color> lstColour = new List<Color>(); foreach (Control c in groupBox1.Controls) lstColour.Add(c.ForeColor); groupBox1.ForeColor = Color.Red; //the colour you prefer for the text int index = 0; foreach (Control c in groupBox1.Controls) { c.ForeColor = lstColour[index]; index++; } } 

Of course, the above code may be pointless if you add controls programmatically later in a group package, but it’s good that you can cope with all situations by adding additional conditions to the code. To be doubly sure, you can use the keyvaluepair management list and forecolor.

0
source

All Articles