2

i drop a Button on a black Form. The button appears fine at design time:

enter image description here

The button also appears fine at runtime (with Visual Styles enabled):

enter image description here

But the button draws completely wrong with visual styles disabled:

enter image description here

How to fix?

Bonus Chatter

  • When dropping a Button on a black form, the button's BackColor sets itself to black
  • By default a Button dropped on a "normal" colored form has a BackColor of Transparent
  • Setting the Button BackColor to Transparent doesn't fix it
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • What make you think there is a problem (as you deactivated visual style)? Also, controls in .NET keep track of whether the backcolor has explicitly been set or is inherited from parent control (which is why the color of your control can use the color of the form). – ken2k Feb 14 '12 at 16:11
  • @ken2k It makes me think it's a problem because a customer reported a problem, which i could reproduce, where "button's are invisible" when running on a server. – Ian Boyd Feb 15 '12 at 12:42

1 Answers1

1

I know this is an old post, but in case someone else comes across it, I managed to solve the issue in my program. In your Program.cs page (or whatever it's been renamed to), ensure you've called Application.EnableVisualStyles before calling Run.

Application.EnableVisualStyles();
Application.Run(new Form1());

Also ensure that the button's UseVisualStyleBackColor property is set to true.

keyboardP
  • 68,824
  • 13
  • 156
  • 205