用渐变色填充区域
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;

namespace 渐变
...{
        /** ////
         /// Form1 的摘要说明。
         ///

         public class Form1 : System.Windows.Forms.Form
        ...{
                /** ////
                 /// 必需的设计器变量。
                 ///

                 private System.ComponentModel.Container components = null;

                 public Form1()
                ...{
                         //
                         // Windows 窗体设计器支持所必需的
                         //
                        InitializeComponent();

                         //
                         // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
                         //
                }

                /** ////
                 /// 清理所有正在使用的资源。
                 ///

                 protected override void Dispose( bool disposing )
                ...{
                         if( disposing )
                        ...{
                                 if (components != null)    
                                ...{
                                        components.Dispose();
                                }
                        }
                         base.Dispose( disposing );
                }

Windows Form Designer generated code #region Windows Form Designer generated code
                /** ////
                 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
                 /// 此方法的内容。
                 ///

                 private void InitializeComponent()
                ...{
                         //    
                         // Form1
                         //    
                         this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                         this.ClientSize = new System.Drawing.Size(728, 494);
                         this.Name = "Form1";
                         this.Text = "Form1";

                }
                #endregion

                /** ////
                 /// 应用程序的主入口点。
                 ///

                [STAThread]
                 static void Main()    
                ...{
                        Application.Run( new Form1());
                }

                 protected override void OnPaint(PaintEventArgs e)
                ...{
                        Graphics g=e.Graphics;
                         //定义一个线性梯度刷
                        LinearGradientBrush lGBrush= new LinearGradientBrush(    
                                 new Point(0, 10),    
                                 new Point(150, 10),
                                Color.FromArgb(255, 255, 0, 0),
                                Color.FromArgb(255, 0, 255, 0));
                        Pen pen= new Pen(lGBrush);
                         //用线性梯度刷效果的笔绘制一条直线段,填充一个矩形
                        g.DrawLine(pen, 10, 130, 500, 130);
                        g.FillRectangle(lGBrush, 50, 150, 370, 30);

                         //定义路径并添加一个椭圆
                        GraphicsPath gp= new GraphicsPath();
                        gp.AddEllipse(10, 10, 200, 100);
                         //用该路径定义路径梯度刷
                        PathGradientBrush brush= new PathGradientBrush(gp);
                         //颜色数组
                        Color[] colors= ...{
                                        Color.FromArgb(255, 255, 0, 0),
                                        Color.FromArgb(255, 100, 100, 100),
                                        Color.FromArgb(255, 0, 255, 0),
                                        Color.FromArgb(255, 0, 0, 255)};
                         //定义颜色渐变比率
                         float[] r = ...{
                                        0.0F,
                                        0.3F,
                                        0.6F,
                                        1.0F};
                        ColorBlend blend= new ColorBlend();
                        blend.Colors = colors;
                        blend.Positions = r;
                        brush.InterpolationColors = blend;
                         //在椭圆外填充一个矩形
                        g.FillRectangle(brush, 0, 0, 210, 110);

                         //用添加了椭圆的路径定义第二个路径梯度刷
                        GraphicsPath gp2= new GraphicsPath();
                        gp2.AddEllipse(300, 0, 200, 100);
                        PathGradientBrush brush2= new PathGradientBrush(gp2);
                         //设置中心点的位置和颜色
                        brush2.CenterPoint = new PointF(450, 50);
                        brush2.CenterColor = Color.FromArgb(255, 0, 255, 0);
                         //设置边界颜色
                        Color[] colors2 = ...{Color.FromArgb(255, 255, 0, 0)};
                        brush2.SurroundColors = colors2;
                         //用第二个梯度刷填充椭圆
                        g.FillEllipse(brush2, 300, 0, 200, 100);
                }
        }
}