using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace WindowsApplication65
{
    public class Button1 : Button
    {
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            Graphics gh = pevent.Graphics;
            Color c1 = Color.FromArgb(0x000000);
            Color c2=Color.FromArgb(0xffffff);
            Point p1=new Point(5,5);
            Point p2=new Point(10,10);
            Brush bs = new LinearGradientBrush(p1, p2, c1, c2);
            gh.FillEllipse(bs, 50, 50, 30, 20);
        }  
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}
怎么没变化,想把button画成个椭圆,然后在有渐变

解决方案 »

  1.   

    GraphicsPath gp = new Graphics();
    gp.AddEllip(0,0,100,50);
    Button.Range = gp;
    就行了
    关键是Button的Range属性的使用!
      

  2.   

    Form1里也没看你用Button1啊。
      

  3.   

    GraphicsPath gp = new Graphics();
    gp.AddEllip(0,0,100,50);
    Button.Range = gp;
    就行了
    ===============
    Range 没有找到这个属性Form1里也没看你用Button1啊。
    ================
    在From1.D....cs里是你的顏色范圍有問題﹐試試將c1,c2換成別的顏色。
    ========================
    换了,从绿色到红色也不行,我刚才用了一下纯色的也不行啊,哪位给个代码把。