tags:

views:

46

answers:

3

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

+1  A: 

Use the following:

this.FormBorderStyle = FormBorderStyle.FixedSingle;  
Kangkan
This is not working at design-time.
JMSA
You can also see: http://stackoverflow.com/questions/1849135/winform-inheritance-designer-settings-are-copied-to-derived-form
Kangkan
There is a place to set this property at design time in the VS designer gui, is that what you are referring to?
TJB
The one I am referring to is making the properties in the base form as read only.
Kangkan
+2  A: 

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
That is not working either.
JMSA
Oh, I think I get you now. How about setting the MaximumSize and MinimumSize to the same value?
George Howarth
+1  A: 

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