System.Drawing.Drawing2D.LinearGradientBrushms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemdrawingdrawing2dlineargradientbrushclasstopic.htm

解决方案 »

  1.   

    如下添加代码可以实现这个效果:private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0,0,this.Width,this.Height),System.Drawing.Color.FromArgb(155, 128, 0),System.Drawing.Color.FromArgb(255, 128, 9),0,true);

    e.Graphics.FillRectangle(p,0,0,this.Width,this.Height);
    }
      

  2.   

    hbxtlhx(下着春雨的天) 
    你那个方法怎么调用啊?参数怎么设置?
      

  3.   

    hbxtlhx(下着春雨的天)
    写的那是Paint事件
    不用自己调用
      

  4.   

    在你的窗体上的panel的事件里找到paint双击就可以添加一个事件处理代码,把我的那段代码放到里面就可以了,就是如下的几句copy一下放到你的paint事件处理代码中就行了:
    Rectangle rect = new Rectangle(0,0,this.panel1.Width,this.panel1.Height);
    System.Drawing.Color color1 = System.Drawing.Color.FromArgb(155, 128, 0);
    System.Drawing.Color color2 = System.Drawing.Color.FromArgb(255, 128, 9);
    System.Drawing.Drawing2D.LinearGradientBrush p=new System.Drawing.Drawing2D.LinearGradientBrush(rect,color1,color2,0,true);e.Graphics.FillRectangle(p,0,0,this.Width,this.Height);
      

  5.   

    new Rectangle(0,0,this.Width,this.Height)//是PANEL 起点(0,0)宽和高分别为panel的宽,高
    System.Drawing.Color.FromArgb(155, 128, 0) //定义颜色;
    System.Drawing.Color.FromArgb(255, 128, 9),//也是定义颜色,好象和上面的一同,一起定义渐变
    e.Graphics.FillRectangle(p,0,0,this.Width,this.Height)//填充这个区域,用上面定义好的
    LinearGradientBrush(……)//是定义刷子
    System.Drawing.Drawing2D //可以直接用using System.Drawing.Drawing2D就不用写那么长了
    ……p=new ……//这个就不用解释了 吧?
     恩
      我 也快晕了!
    好运!