Click here to Skip to main content
15,894,740 members

Comments by Smeezy (Top 34 by date)

Smeezy 3-Feb-20 10:01am View    
Understood. Again, thank you!
Smeezy 3-Feb-20 9:56am View    
I really appreciate your help Richard! This was enlightening if for no other other reason than to reinforce the knowledge that I have a long way to go! I do need to ask though, why was this not as simple as it was to do with the backcolor?
Smeezy 3-Feb-20 9:54am View    
OK. I just figured that out. I forgot to add the save dialog back in!
Smeezy 3-Feb-20 9:49am View    
Not sure I'll ever get beyond where I'm at with coding! This is kind of working now. Regardless of what color I choose, when I reopen the program, the forecolor of all labels is red. I don't see where that is coming from.

//Allows user to set Label ForeColor and saves as a default color.
private void btnFcolor_Click(object sender, EventArgs e)
{
using (var dlg = new ColorDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
SetLabelColor(Controls.Cast<control>(), dlg.Color);
}
}

private void SetLabelColor(IEnumerable<control> controls, Color color)
{
foreach (Label label in controls.OfType())
{
label.ForeColor = color;
}
foreach (Control control in controls.Where(c => c.HasChildren))
{
SetLabelColor(control.Controls.Cast<control>(), color);
}
}
private void Form1_Load(object sender, EventArgs e)
{
SetLabelColor(Controls.Cast<control>(), Properties.Settings.Default.FormForeColor);
}
Smeezy 3-Feb-20 9:36am View    
I did not set that. Is that as simple as putting "SetLabelColor;" in the Form1_Load?