Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I prevent resizing of a custom control in the designer?

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:

using System.Windows.Forms.Design;

public override SelectionRules SelectionRules 
{ 
  get 
  { 
    SelectionRules selectionRules = base.SelectionRules; 
    if ( Control.Parent is CustomControlParent ) 
      selectionRules &= ~(SelectionRules.AllSizeable); 
    return selectionRules; 
  } 
}

Contributed from George Shepherd's Windows Forms FAQ



Page view counter