我正在开车Button
,我希望这个新的自定义按钮始终为 20 x 20 像素。我在默认值和我自己实现的构造函数中都写了Width
和Height
20,但是如果我将控件从工具箱拖到设计器中,或者我以编程方式将控件添加到表单中,这不会改变任何东西。
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;
}
}