Search code examples
c#winformsformsbackgroundbackcolor

Form background color or image stuck as white


I started teaching myself C# a week ago. I started by writing Tetris to get myself acquainted with the language. I got the main game mechanics working by painting onto presized bitmap and displaying it in a picturebox, which at the time was the same size of the window. Now I have expanded the windows size and started adding other controls to the side of the picture box.

The problem is, now that I have expanded the window, displaying the form background, the background color is permanently white or I get a weird white to black faded look in the bottom corner.

I have tried several things:
   - set the form backcolor manually, but it is only reflected on the labels
   - checked that the transparencykey is empty
   - set transparencykey to an unused color, nothing changes
   - added a bmp as the form's background image, still stays white
   - checked my code to see if I was every writing directly to the form background

I can't fingure out how to fix this; does anyone have any ideas?

EDIT:
I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my constructor. I'm not sure what exactly that does, but I commented it out and it fixed my problem.


Solution

  • I found the answer to my question. SetStyle(ControlStyles.Opaque, true) was called in my initialization. I'm not sure what exactly that does, but it was the cause of my background color issue.