C# 如何在自定义控件中通过用户定义/选择在开发时设置FillEllipse颜色

C# 如何在自定义控件中通过用户定义/选择在开发时设置FillEllipse颜色,c#,winforms,events,custom-controls,system.drawing,C#,Winforms,Events,Custom Controls,System.drawing,在这里,您可以看到文本的控件属性,并且以类似的方式,我想做一些类似-FillEllipse的事情,应该能够决定用户希望从属性栏中选择哪种颜色(显示右侧) 例如,这里给出了“粉色”,所以每当用户拖放我的自定义控件时,他都会看到粉色椭圆,但我希望用户可以从右侧属性窗口中选择任何颜色。。。作为矩形背景色属性 public new string Text { get { return base.Text; } set { if (v

在这里,您可以看到文本的控件属性,并且以类似的方式,我想做一些类似-
FillEllipse
的事情,应该能够决定用户希望从属性栏中选择哪种颜色(显示右侧)

例如,这里给出了“粉色”,所以每当用户拖放我的自定义控件时,他都会看到粉色椭圆,但我希望用户可以从右侧属性窗口中选择任何颜色。。。作为矩形
背景色
属性

public new string Text
{
    get
    {
        return base.Text;
    }
    set
    {
        if (value == base.Text)
            return;
        base.Text = value;
        Invalidate();
    }
}

protected override void OnPaint(PaintEventArgs e)
{
    Graphics gfx = e.Graphics;
    Rectangle rc = ClientRectangle;
    rc.Width -= 1;
    rc.Height -= 1;
    gfx.FillRectangle(new SolidBrush(Parent.BackColor), ClientRectangle);

    gfx.DrawEllipse(new Pen(Color.Blue, 4.0f), rc);
    gfx.FillEllipse(new SolidBrush(Color.Pink), rc);
    //gfx.FillEllipse(true, rc);
    //gfx.FillEllipse(jj, rc);
    //gfx.FillEllipse(
    Font fnt = new Font("Vardhana", (float)rc.Height * 0.3f, FontStyle.Bold,GraphicsUnit.Pixel);
    StringFormat sf = new StringFormat();
    sf.Alignment = StringAlignment.Center;
    sf.LineAlignment = StringAlignment.Center;
    gfx.DrawString(Text,fnt,new SolidBrush(Color.Blue),new RectangleF((float)rc.Left, (float)rc.Top, (float)rc.Width,(float)rc.Height),sf);                
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
    base.OnPaintBackground(pevent);
}
谢谢“LarsTech”提供的提示,在你的帮助下,我终于自己找到了解决方案。 因此,正如你所建议的,我添加了属性

public new Color EllipseColor
        {
            get
            { return base.BackColor; }
            set
            {
                if (value == base.BackColor)
                    return;
                base.BackColor = value;
                Invalidate();
            }
        }
在代码中做了一些替换,效果很好

//    gfx.FillEllipse(new SolidBrush(Color.Pink), rc);
      gfx.FillEllipse(new SolidBrush(EllipseColor), rc);

是什么阻止了您创建EllipseColor属性?您能告诉我创建EllipseColor属性的代码吗?