I am having trouble with background colors in C#. For some reason they are simply not working. Specifically on the System.Windows.Forms.Panel control. Setting the BackColor property does nothing. All I have is gray and all the efforts I have made will not change it. Is there something that could be overriding this? Am I approaching this the wrong way?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
It may be that your control is being repainted without your knowledge.
To try to rule this out, I would add a Form Load event, and force the following properties:
And on the designer, I would bring the control to the foreground.
I had this problem with two overlayed panels in one form. I inadvertently had one panel as a child of the other main when I created them in Design View.
I have had instances where controls must have both the foreground and background colors specified, you might want to try setting the foreground color explicitly as well, to see if that works.
If you want to have the Panel Control the same color as the Form's background color, then you can use this:
... I hope this helps :)