奇怪的xx
小弟我写了一个小程序,背景加了一个渐变的颜色,像这样子的:
可是我把这个小程序最小化再还原窗口,就变成这样子的:
究其原因,就是如下这段渐变颜色的代码,删掉就不会有问题了:
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Color FColor = Color.AliceBlue;
Color TColor = Color.BlueViolet;
Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.Vertical);
g.FillRectangle(b, this.ClientRectangle);
}
try
{
Graphics g = e.Graphics;
Color FColor = Color.AliceBlue;
Color TColor = Color.BlueViolet;
Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.Vertical);
g.FillRectangle(b, this.ClientRectangle);
b.Dispose();
}
catch
{
this.Invalidate();
}