Search code examples
c#user-controlsdesigner

Hide resize markers in designer using C#?


Usually when you select a control in designer it will show resize markers (little white square boxes) around it. I want to make my control non-resizable , and I partially implemented it by setting the size in OnPaint but the markers are still being shown and you can still drag them (but the control returns to it's previous size immetiatedly).

How do I hide the markers (like a label with Autosize on)?

(I am overriding AutoSize property)

    [BrowsableAttribute(true)]
    public override bool AutoSize {
        get
        {
            return autosize;
        }
        set
        {
            autosize = value;
            this.Invalidate();
        } 
    }

Solution

  • You need to implement a custom designer (ControlDesigner) for your control and then override the SelectionRules property.