How do I prevent resizing of my Control in the designer?

Platform: WinForms| Category: Custom Designers

You normally need this support when your Control is parented by another custom Container Control that manages the location and size of your Control.

You can prevent resizing by overriding this method in your custom ControlDesigner class:


protected override bool EnableDragRect 
{
	get { return false; }
}

Or, for more control over the resizing process:


public override /*ControlDesigner*/ SelectionRules SelectionRules 
{ 
	get
	{
		System.Windows.Forms.Design.SelectionRules selectionRules;
		System.Windows.Forms.Control control;
		selectionRules = base.SelectionRules;
		control = this.Control;
		if (control.Parent is MyControlParent)
			selectionRules = (SelectionRules)(selectionRules & ~(SelectionRules.AllSizeable));

		return selectionRules;
	}
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.