Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 293
Maixy Avatar asked Aug 25 '10 23:08

Maixy


People also ask

How to fix windows form size in c#?

Right click on your form and go to properties. Then go to Layout options,see there are a property named Size. Change it as your need as width and length wise.

Is it possible to resize a control within the form design window?

To resize multiple controls on a form In Visual Studio, hold down the Ctrl or Shift key and select the controls you want to resize. The size of the first control you select is used for the other controls.

What is used to move and resize the controls on the form window?

By default, the controls on an Access form stay anchored to the upper-left corner of the form, and do not resize when you resize the form. To change this behavior, you can use the Anchoring command.


2 Answers

Autosize (which was set on the main Form object) was preventing the window from decreasing to a size smaller than the objects contained within it. As the objects within the main Form increased on each expansive resize, the main Form was unable to shrink after any resize growth. By disabling Autosize on the main Form object, I was able to regain full control of resizing.

like image 178
Maixy Avatar answered Sep 20 '22 22:09

Maixy


If the above does not solve it, check that the form minimum size is not set to a value larger than you need.

like image 20
Shaner Avatar answered Sep 23 '22 22:09

Shaner