If I draw a rectangle wider than 202 pixels wide LinearGradientBrush, I get a color frame on the left:

Given the code for a large rectangle of 202px :
private void MainForm_Paint(object sender, PaintEventArgs e)
{
Rectangle r = new Rectangle(50, 50, 202, 50);
Color color1 = Color.FromArgb(unchecked((int)0xFF00024d));
Color color2 = Color.FromArgb(unchecked((int)0xFFd6a20f));
Brush b = new LinearGradientBrush(r, color1, color2, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(b, r);
}
I get a rectangle that draws correctly:

But if I change the rectangle to 203 pixels wide:
Rectangle r = new Rectangle(50, 50, 203, 50);
The rectangle has a colored frame or wrap on the left:

This also happens in the vertical direction with LinearGradientMode.Vertical:
202px

203px

source
share