What's preventing me from resizing (downsizing) my windows form object?

Viewed 35887

I've got a windows form object that contains 3 objects, a treeview, a richtextbox, and a tabcontrol. They are not docked into the windows form, but they are anchored (top+left).

I've written the code to resize them when a form-resize event handler gets called, but it only seems to be working for an increase of form size, that is to say, I can't resize the form to a smaller size. This includes times when I first increase the main windows form and then attempt to return it to its original size.

The sizes of the three objects are manually set after each Form resize with the code below:

        treeView1.Height += (this.Height - oldHeight);
        richTextBox1.Width += (this.Width - oldWidth);
        tabControl1.Width += (this.Width - oldWidth);
        tabControl1.Height += (this.Height - oldHeight);
        oldHeight = this.Height;
        oldWidth = this.Width;

None of the objects have a set minimum size (they are all at 0,0 throughout the resizing process)

What is preventing the form from being resized to a smaller size?

9 Answers

Just change default MinimumSize in form's properties to a number other that zero (like 10)

Check the Min Widths and Min Heights

enter image description here

Designer view:

enter image description here

As you can see, if you set the Min width and Min height, while having auto size set to false, then the buttons are now the size you want it to be :)

I followed all the answers here, none worked for me. I went ahead and added the padding and it worked. head over to properties tab selecting the label and add padding.

I was able to resolve this for myself (found this question while looking for my own answer) by setting the FormBorderStyle to SizableToolWindow. It appears the Sizable border style has some sort of default minimum width baked into it (I couldn't get it below 136), while SizableToolWindow does not.

Related