I am drving from Button and I want this new custom button to be always 20 by 20 pixels. I wrote in the default and my own implemented constractor both the Width and Height to be 20 but this does not change anything if I drag the control from toolbox into designer or I programatically add the control to form.
public partial class PinButton : Button
{
public PinButtonData Data { get; set; }
public PinButton()
{
InitializeComponent();
Height = 20;
Width = 20;
}
public PinButton(PinButtonData data)
{
InitializeComponent();
Height = 20;
Width = 20;
Data = data;
}
}
You should override the
SetBoundsmethod and pass20as the height and width parameters in the base call.