I've made a custom control and overridden SetBoundsCore
such that the height of the control is fixed. I'd like the designer to show the same sort of resize boxes as the NumericUpDown
has - just one at each end - so that it's clear that the control has a fixed height. How do I tell the designer that my control has a fixed height?
You have to apply a Designer
attribute to your UserControl
:
[Designer(typeof(UCDesigner))]
public partial class UserControl1 : UserControl {
public UserControl1() {
InitializeComponent();
}
}
The UCDesigner
class is defined as follow:
class UCDesigner : System.Windows.Forms.Design.ControlDesigner {
public override System.Windows.Forms.Design.SelectionRules SelectionRules {
get {
return (base.SelectionRules & ~(SelectionRules.BottomSizeable | SelectionRules.TopSizeable));
}
}
}
Note: You'll have to add a reference to the System.Design namespace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.