我制作了一个自定义控件并覆盖了SetBoundsCore,这样控件的高度就是固定的。我希望设计器显示与NumericUpDown相同的调整大小的框--两端只有一个--这样就可以清楚地看到控件有固定的高度。如何告诉设计器我的控件有固定的高度?
发布于 2009-07-24 10:05:38
您必须对UserControl应用Designer属性
[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名称空间的引用。
https://stackoverflow.com/questions/1176433
复制相似问题