Custom Control Overriding Command Button

Posted by pm_2 on Stack Overflow See other posts from Stack Overflow or by pm_2
Published on 2010-04-25T12:46:59Z Indexed on 2010/04/25 12:53 UTC
Read the original article Hit count: 217

Filed under:
|
|

I am trying to create a custom command button that defaults width and height to specific settings. I have the following code:

public partial class myCommandButton : Button
{
    public magCommandButton()
    {
        InitializeComponent();

    }

    [DefaultValue(840)]
    public override int Width
    {
        get 
        {
            return base.Width;
        }
        set
        {
            base.Width = value;
        }
    }

    [DefaultValue(340)]
    public override int Height
    {
        get
        {
            return base.Height;
        }
        set
        {
            base.Height = value;
        }
    }

    protected override void OnPaint(PaintEventArgs pe)
    {
        base.OnPaint(pe);
    }
}

However, it won't compile because it tells me that I can not override Width or Height. Can anyone tell me if I'm approaching this wrongly, or if there's a way around this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms