I have no idea why this is happening, but I created the below code which is a gradient panel, the panel is then docked to the left of the screen.
When the form is re
I'm doing something similar, but even cleaning up the LinearGradientBrush didn't fix it for me. Looking at the console output, I noticed "A first chance exception of type System.ArgumentException occurred in System.Drawing.dll." I believe this is because the ClientRectangle is 0,0 when the component is minimized. Adding this code seemed to fix it for me:
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
if (this.gradientBrush != null)
this.gradientBrush.Dispose();
if (this.ClientRectangle.Width > 0 && this.ClientRectangle.Height > 0)
{
this.gradientBrush = new LinearGradientBrush(this.ClientRectangle,
FROM_GRADIENT_COLOR, TO_GRADIENT_COLOR, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(this.gradientBrush, this.ClientRectangle);
}
}