views:

111

answers:

1

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?

+2  A: 

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.

Julien Poulin