Is there a reason why a .NET WinForms TabPage
doesn't fully repaint its background when I resize the Form? It should be completely white (in Windows 7), but a portion remains gray (SystemColors.Control
, most likely). Whenever I hit the maximize button, currently visible TabPage
background doesn't get redrawn. Also, if I resize it, I need to move the form past the screen boundaries in order for it to get painted.
The same thing happens if I minimize and then restore the form. In that case the TabPage
background remains grey. Child controls are rendered properly (labels, for example, keep their white backgrounds).
I am using Windows 7 32-bit, .NET 3.5. Tab control was added using the Visual Studio designer, and contains a couple of labels and two text boxes. I haven't changed any native style flags related to paint messages.
[Edit]
I have created a test project, source is uploaded here.
This is how the window looks initially:
This is how the window looks after I minimize it and then restore it:
Note the change in TabPage
background color.
I fixed this by adding a call to tabControl.Refresh() inside the tabControl's ClientSizeChanged method. Note that that's for the overall Tab Control and not each individual Tab Page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With