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;
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.
source share