I'm disabling a button in vb.net and when I do, I cannot control the BackColor or ForeColor properties to change the appearance. I set new values for them but they don't get picked up. The disabled button looks almost exactly like my enabled buttons so you can't tell the difference. I'm using Flat Style buttons, but have tried changing this and it still doesn't seem to work. Is there some sort of trick to be able to do this?
Asked
Active
Viewed 2,327 times
7
-
Could you post some code? It's working for me. – Dave Mateer Jan 20 '10 at 18:16
-
Works just fine when I try it. – Hans Passant Jan 20 '10 at 18:20
-
Part of the problem may be that I'm updating buttons that are created in a User Control after they've been created. I will work on putting together some sample code that will recreate the issue. Thanks. – Shawn Steward Jan 20 '10 at 20:24
-
I'll keep an eye out if you post some code. Sounds like an interesting challenge. I'm deleting my answer below since its obviously irrelevant. – Dave Mateer Jan 21 '10 at 13:44
1 Answers
5
I ran into a similar problem in VB.NET 2008.
When I set the background color of a textbox to something other than the default at design time, then when I disabled that textbox at runtime, it did not get that 'disabled' look; the background color remained unchanged. To get around this, I had to override the OnEnabledChanged method and manually set the background to what I needed.
This is a little different than the problem you have, but I think that overriding the OnEnabledChanged method might help you out.

Stewbob
- 16,759
- 9
- 63
- 107