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?
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.
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.
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.
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.
If the above does not solve it, check that the form minimum size is not set to a value larger than you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With