1. c#中,用g.drawline画竖线从而实现从左到右颜色的渐变,应该怎么编程序

//Form1的Paint事件处理函数
privatevoidForm1_Paint(objectsender,PaintEventArgse)
{
Graphicsg=e.Graphics;

//渐变色:起点(0,0)从红色--->终点(250,250)蓝色
LinearGradientBrushbrush=newLinearGradientBrush(
newPoint(0,0),newPoint(250,250),
Color.Red,Color.Blue);

Penpen=newPen(brush);

//画线
g.DrawLine(pen,50,50,300,50);

pen.Dispose();
brush.Dispose();
}