I have a Winform I want to resize. Not after launching; I want to resize it in the designer by dragging the edges.
I am aware that I can change the size manually in the form properties. This is not what I want to do. I want to quickly size the default size of the form with my mouse.
The problem appears to be that I cannot grab the edges of the form for some reason. I repeat, this is NOT DURING RUNTIME. It is not that I have disabled/enabled Autosize/Resizing.
It's almost like the edge grabs are a single pixel wide and I just can't hit it. I don't know. I've looked for accessibility settings. The last thing I want to do is reinstall MSVS. It's just maddening.
I've attached a photo. The little boxes on the bottom, right, and bottom-right corner are my targets.
you can try to click the form title before resizing. I think you may have a panel (or any container control) which is full docked in the form, that's why when you click the form body, you selected the panel instead of the form.
Another issue that I encountered was the windows font size was set to 120% (or more), so go to windows display setting and set the font size to 100%.
I have a problem when working with a form that has a fixed size.
When I resize Visual Studio windows, the form resizes as well, even when being locked. It is a huge inconvinience because I can't get an idea of how my design would end up.
I am working with a fixed size aplication, that has a MDI child form.
I need the form to have FormBorderStyle to None, so I can't set it to something fixed.
Image of the form with desired size
Image of the form with deformed size
Set the MinimumSize and MaximumSize properties of the form to the desired size. This makes the from size fixed.
Note, this trick also works for single-line TextBox controls, if you want to set the height to a different height than the one automatically determined from the font size.
I want to fix the resolution of my main form, I can set the number of pixels using
this.Height = 480;
this.Width = 640;
But I want some way to make it constant, so that even if the frame is enlarged, the number of pixels will not change, but their size.
By setting the option AutoSizeMode to GrowAndShrink I can prevent re-sizing of the form by dragging the edges of the form, but when the maximize button is pressed, the form becomes big and adds new pixels. I want to allow the re-sizing of the form and putting it in maximized or fullscreen mode without changing the number of pixels in the form, or in other words, enlarging the size if the current pixels, instead of adding new pixels.
Is there a way too do it?
Pixels are fixed units. You probably would like WPF since its a vector based system.
Is it possible to create a form in C# that has formBorderStyle set to sizable but the user can't resize the form?
I know i can set the maximumSize and minimumSize to the same size and this will prevent resizing the form, but the cursor will still changes to resize when hovering over the border. And i don't want that.
I could use formBorderStyle = fixed but i am using sizable so the form looks like a windows 7 window. Is it possible to use "fixed" and apply some styles to the form so it looks like a sizable form (with the borders, transparency and the shade effect).
Thanks in for the reply's,
J.
EDIT:
Found the solution here:
How to create a form with a border, but no title bar? (like volume control on Windows 7)
Is FixedSingle not work for you? Forms are looking in the Windows 7 style too.
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?
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.
Right click your Winform in Visual studio -> select properties ->AutoSize will be set True -> Change it to False
OR
Include this line in your code
this.AutoSize = false;
There may be one more way to correct the behavior of a form which cannot be resized by normal mouse selection.
Related to the discussion above, I discovered (using VB.net in VS2010) that one of my standard Windows forms would not resize with mouse selection. It is as though the FormBorderStyle was set to Fixed . Even changing FormBorderStyle to SizableToolWindow did not give the expected mouse-sizable behavior.
Here are some form settings from the form design Properties:
Autosize: false
AutoSizeMode: growonly
Doublebuffered: true
Enabled: true
FormBorderStyle: Sizable
ImeMode: NoControl
Locked: false
AutoScaleMode: Font
AccessibleRole: default
All of the visible or code Property settings of this form, and all of its Designer property settings too, were identical to other forms in the same project that would properly allow mouse resizing. Cleaning the solution, and Rebuilding it also did not fix the problem of the frozen form. Clicking Maximize did work, and so did click Minimize. The form size could be set by code as expected. Only mouse resizing of the form did not function properly.
I discovered that the desired mouse-selection resizing could be again enabled by setting, in code, by setting the parameter:
myForm.AutoScaleMode = Windows.Forms.AutoScaleMode.Inherit
This parameter had been set to .Font in the design of the form, which was also used in other forms that worked properly.
Then... strangely... changing it back from .Inherit to .Font in code also allowed the form to resize properly.
That setting in code (either to .Inherit, or to .Font) seemed to be the critical element to correct the form resizing trouble, in this case. It seems there are hidden parameters which the system does not show the user that somehow interfere with the expected operation of a form.
Just change default MinimumSize in form's properties to a number other that zero (like 10)
Just put all your Controls into a Panel and set Dock property of the Panel to Fill. I believe it works even with Autosize set to true.
Check the Min Widths and Min Heights
Designer view:
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.