Environment: Visual Studio 2005
Language: C# or C++.NET
By means of AutoSize and Dock, it is very easy to obtain that sizing the form will automatically resize the controls it contains, a situation that may be logically represented as:
Size Form -> Auto Size Controls
I would like to obtain the opposite:
Auto Size Form <- (Auto) Size Control(s)
I have a multiline TextBox and/or DataGridView and I want to be able to select the font that will be used inside this/these controls. When I change the font, I want that the entire Form resizes, together with the controls, in order to keep in view exactly
a specified number of rows and columns without clipping or wrapping. Thus if I select a larger font, the control and the entire Form must enlarge; if I select a smaller font, they must shrink.
I wonder if there is a simple method to obtain this. If there is none, I figure my program must calculate the required size for the Form and programmatically re-size it. Then, the controls will resize accordingly. The sequence would be:
1. Select font -> calculate required total size of the Form window
2. Resize myForm
3. The controls automatically resize
After I select the font, I multiply myFont.Height by the desired number of rows, take into account the other items in the form, and obtain the required total height.
Similar calculations should be made for the width, but it's le
View Complete Post