public Form1()
{
InitializeComponent();
int x = this.Location.X+10;
int y = this.Location.Y+10;
int height = this.Size.Height, width = this.Size.Width;
Bitmap bm = new Bitmap(height, width);
Graphics g = Graphics.FromImage(bm);
g.Clear(Color.White);
Pen p = new Pen(Color.Black, 1);
// LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, bm.Width, bm.Height),Color.Blue, Color.BlueViolet, 1.2f, true);
g.FillRectangle(Brushes.White, x, y, width, height);
g.DrawRectangle(new Pen(Color.Blue), 0, 0, bm.Width - 1, bm.Height - 1);
g.DrawLine(p, x, y, x, y + 140);
g.DrawLine(p, x, y, x + 140, y);
}
你的g.FillRectangle(Brushes.White, x, y, width, height);颜色有关吧。改一个颜色试试。
把画的代码 放在 onPaint()函数里试试!