When I try to programmatically change a button's text color on my winforms form, it doesn't work. I have this code:
btnTestConnection.Text = "Valid connection";
btnTestConnection.Font = new Font(btnTestConnection.Font, FontStyle.Bold);
btnTestConnection.BackColor = Color.Green;
btnTestConnection.ForeColor = Color.White;
This seems bizarre. I have verified that nothing downstream changes the forecolor back to black. What am I missing?
I am using VS 2017 and compiling my project against .NET Framework 4.5.2.
I figured it out. My button is disabled at the time the ForeColor property is being set to white. Apparently winforms won't allow a disabled button to have its ForeColor property changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With