如何重置一个.NET Windows窗体文本框背景色属性?窗体、文本框、背景色、属性

2023-09-04 00:11:34 作者:亡徒i

属性背景色的默认行为文本框如下:当启用时,它 SystemColors.Window ),当禁用它格雷(不知道是什么的SystemColor这是)。

The default behavior of property BackColor of a TextBox is as follows: when enabled, it is White (SystemColors.Window), when disabled it is Gray (not sure what SystemColor this is).

如果我修改背景色属性,相同的颜色用于启用和禁用的。我如何重置背景色属性(后已更改previously),这样的行为将恢复为默认?

If I change the BackColor property, the same color is used for both Enabled and Disabled. How do I reset the BackColor property (after it has been changed previously) so that the behavior reverts to the default?

我已经尝试设置回 SystemColors.Window ,但随即被禁用时,盒子保持白色。

I have tried setting it back to SystemColors.Window, but then the box stays white when disabled.

推荐答案

如果您在设计师的意思是,你可以点击进入背景色属性并删除无论是在那里,然后preSS进入。这将重置属性恢复为默认值。

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.

如果您在code的意思是,你可以设置背景色属性设置为Color.Empty,这将有同样的效果。

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