我已经制作了自定义控件并覆盖了SetBoundsCore
,以便控制的高度是固定的。我希望设计师能够像NumericUpDown
一样显示相同类型的调整大小 - 每端只有一个 - 这样很明显控件具有固定的高度。如何告诉设计师我的控件有一个固定的高度?
答案 0 :(得分:4)
您必须将Designer
属性应用于UserControl
:
[Designer(typeof(UCDesigner))]
public partial class UserControl1 : UserControl {
public UserControl1() {
InitializeComponent();
}
}
UCDesigner
类定义如下:
class UCDesigner : System.Windows.Forms.Design.ControlDesigner {
public override System.Windows.Forms.Design.SelectionRules SelectionRules {
get {
return (base.SelectionRules & ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable));
}
}
}
注意:您必须添加对System.Design命名空间的引用。