How do I reset a .NET Windows Forms TextBox BackColor property?

前端 未结 4 981
我在风中等你
我在风中等你 2020-12-17 15:32

The default behavior of property BackColor of a TextBox is as follows: when enabled, it is White (SystemColors.Window), w

相关标签:
4条回答
  • 2020-12-17 16:02
    TextBox.ResetBackColor()
    

    It doesn't pop up in IntelliSense for some reason, but it's there and it compiles.

    0 讨论(0)
  • 2020-12-17 16:02

    In case there is no way to reset the control so it will return to automatically changing its background color when enabled/disabled I would recommend using the UIElement.IsEnabledChanged event to set your desired enabled/disabled background colors. I hope this is helpful!

    0 讨论(0)
  • 2020-12-17 16:04

    SystemColors.Window is (usually) white. Use SystemColors.Control.

    You could, of course, cache the color in use when you set it to your own, then use that to reset it. In the end, though, either approach will work.

    0 讨论(0)
  • 2020-12-17 16:08

    If you mean in the designer, you can just click into the BackColor property and delete whatever is in there and then press enter. This will reset the property back to its default value.

    If you mean in code, you can set the BackColor property to Color.Empty, and this will have the same effect.

    0 讨论(0)
提交回复
热议问题