Search code examples
.netformswinformswindowssystemcolors

Is there a way to change the Default Color for all disabled items in a .NET windows application form?


The text shading difference between enabled and disabled controls is so slight that I couldn't tell the difference at first when building it for the first time.

When I display the ForeColor property for button, label, text titles, etc. they show up as SystemColor.ControlText whether they are disabled or enabled, but they are definitely different.

So it leaves me wondering how the "disabled" effect works and what could be wrong with my Form that makes it so slight a difference.

I tried setting the ForeColor to something different, even Red, but unless I enable to control it doesn't show

So is there a property I'm missing?

Is there a default property for this at the Form level?


Solution

  • There is no property you are missing or a default form property for this. I think you are going to have to write custom controls for this behaviour and override the OnPaint event. Fun but quite a bit of work.

    The RichTextBox could be a workaround for TextBoxes. A simple case of capturing the EnabledChanged event.

    private void richTextBox1_EnabledChanged(object sender, EventArgs e)
    {
            richTextBox1.ForeColor = richTextBox1.Enabled ? Color.Black : Color.Red;
    }