4

In my application I am deriving all my forms from a common BaseForm.

Now I need to disable the resizing in the BaseForm so that derived forms are not resizable at design-time.

How to achieve that?

I need it at design-time

user366312
  • 16,949
  • 65
  • 235
  • 452
  • I think I get you now, I updated my answer. – George Howarth Jul 10 '10 at 08:49
  • possible duplicate of [How can I prevent users from changing the window/form size when application is running](http://stackoverflow.com/questions/1330339/how-can-i-prevent-users-from-changing-the-window-form-size-when-application-is-r) – bluish Aug 25 '15 at 12:46

4 Answers4

10

This seems to work:

[BaseForm.cs]

namespace WindowsFormsApplication1
{
    using System.Windows.Forms;

    public partial class BaseForm : Form
    {
        public BaseForm()
        {
            InitializeComponent();

            this.MaximumSize = this.MinimumSize = this.Size;
        }
    }
}

[DerivedForm.cs]

namespace WindowsFormsApplication1
{
    public partial class DerivedForm : WindowsFormsApplication1.BaseForm
    {
        public DerivedForm()
        {
            InitializeComponent();
        }
    }
}
Adel Hazzah
  • 8,737
  • 2
  • 20
  • 16
4

i used

this.FormBorderStyle = FormBorderStyle.FixedDialog;

this make window form as like dialogBox. so dialog boxes are not resizable by user.

paraguma
  • 187
  • 1
  • 1
  • 7
3

Use the following:

this.FormBorderStyle = FormBorderStyle.FixedSingle;  
Kangkan
  • 15,267
  • 10
  • 70
  • 113
  • You can also see: http://stackoverflow.com/questions/1849135/winform-inheritance-designer-settings-are-copied-to-derived-form – Kangkan Jul 10 '10 at 10:42
  • 1
    There is a place to set this property at design time in the VS designer gui, is that what you are referring to? – TJB Jul 11 '10 at 04:00
  • The one I am referring to is making the properties in the base form as read only. – Kangkan Jul 11 '10 at 16:37
2

If you go into design view and look in the form's properties menu, there is a Locked property, which disables resizing of the form.

EDIT

Try setting the MaximumSize and MinimumSize properties to the same value.

George Howarth
  • 2,767
  • 20
  • 18