How to limit the Design surface area of a form? [duplicate] - c#

I am designing a form in c#. I want to specify the "Client-Area" of the form in the designer.
The Size property sets the size of the complete form, including the NC area. Is there any way to set the client area size?

Have you looked at the ClientSize property? This property allows you to modify the size of the client area of the control. Seems to be what you're looking for.
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.clientsize.aspx

Related

C# form adjusting screen resolution without sizable

I have created a c# windows forms program with a Form which includes a Diagram, an image and Buttons. When I open the program the Form to big for the computer screen this is because the screen resolution is to big or to small.
How can I make the Form exactly right for each screen resolution type whiteout using sizable?
The problem is because you define (Pixel) sizes for your controls and therefore also your Form.
You can put your space consuming controls (diagrams, images) into Panels and then set the Dock property appropriately (on the controls and/or the panels) so that they scale out to their maximum size. This way you can reduce the size of the Form and because you define ratios rather than pixel numbers the controls/labels will expand as needed.
Depending on how you want it to look like you will have to play with different configurations (one or two controls in one label and then setting dock either to fill or left/right/top/bottom). There's also the SplitContainer control to help you achieve certain design goals.
Additionally, if you always want the perfectly scaled window, open the form in Maximised mode:
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

Windows Forms: Auto Scale Application

I have a WinForms Application that was designed to support Full HD resolutions (so 1920x1080). Now this App is also supposed to run on a lower resolution: 1600x900.
Is there a way to let the application auto scale itself to fit the lower resolution? Like you would just downscale an image, basically resizing and relocating each control.
My current forms and panels have set their size to 1900x1080, so they just extend out of the screen on the lower resolution.
I have played around with AutoScaleModes and AutoSize, but the best I could get were Scrollbars so that you at least navigate through the forms. Is such a thing as downscaling an application even possible (retaining dimensions/ relative sizes and positions of the controls)?
Thanks in advance for any inputs on this!
If your main form starts in a maximized mode, it will adjust its size automagically.
But (and this is a huge "but" according to your question): the inner controls won't be scaled as you would see on a smartphone. WinForm is not "vector based" as WPF. If you have a fully loaded form in 1920x1080, when the main form is sized down, the controls won't fit and you will get scrollbars.
So the answer is: No.
The solution is available.
Form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
and
Make all control autosize = false.
make a suitable size of your wish.
The property you are looking for is called Dock, it's a property of the controls.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock(v=vs.110).aspx
This basically tells the control how to fill the available space.
Creating a resolution independent application is not a simple logic. Everything in the window should be resize as per the selected resolution. Not only controls' size you have to change the font size also as per the changes. Here is the example how to create a resolution independent form using C# code. Another way is use DevExpress Tool. This tool provides Layout Countrol Container. You can place each control in separate layout item and assign the minimum and maximum size of control.

Auto size property of Form in VB6

Is there any auto re-size property of form in vb6 with respect to the control size ?
like this.Auto Size = false in c# ?
Your question can be interpreted in more than one way.
If you are asking if controls can be set to automatically resize in VB6 forms then the answer is no, resizing controls when the form resizes has to be done in code. It's not that hard if you're careful about how you design the form.
If you are asking if there is a way to set whether or not a form can be resized then you can use the BorderStyle property of the form, there are various options depending on what you want.

Winforms and contents to run on any resolution

I have a problem with getting my content in a WinForm application to properly resize to fit any screen resolution, How can I solve this?
I used
this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
The size of the form was successfully changed according to the computer's resolution but the contents were not.
The controls inside of a WinForms form do not change based on the size of the form. Textboxes, radio buttons, etc are based on a specific pixel size and do not vary by resolution.
You have to develop your form to work with different resolutions. You will want to use lots of panels with the DockStyle set appropriately. You can hide panels that won't fit (though you might need to provide an alternate way to get to them).
If you need it to change based on resolution, you might want to look into WPF.
For winforms Dock and Anchor properties can help you on this. But they are not powerful as new WPF features (Eg: viewBox). Containers like SplitContainer and Panels can be resized properly with the Dock property. But there is no easy+nice ways to resize child controls like buttons, labels. Those child controls are also support for Dock/Anchor properties though.
Below are some useful articles for your reference.
Article 1
Article 2

Dock, Anchor and Fluid layouts in Windows Forms Applications

So, I've been asked to redesign an old application I wrote a few years ago.
Basically, nothing much needs to be changed, except that the Customer wants it to be more fluid, and that it must be fullscreen (no visible "window") I.e. no Titlebar, just a Borderless fullscreen Window.
What is the best way to make sure everything stays fluid, I mean how can we make sure everything appears where it should, 'cause you know, different resolutions, monitor sizes etc?
This is easy in web pages/css, but this is not something I've done before. Most of the Controls will be created programatically at runtime, based on what action was performed, etc. How would I accomplish such a layout? Basically I want to be able to lay it all out full screen, without knowing how large their monitor is, or what resolution they're using.
Your certainly correct in trying to design your form using a fluid layout that responds to the size of the available space and size of the form font. To do that you want to use the following controls and control properties.
1, TableLayoutPanel will split an area into a set of rows and columns and allow you to position your child controls within individual cells of that table layout. This responds to a change in the form width and height.
2, FlowLayoutPanel will position your child controls from left to right and automatically move to a new row when you run out of space. This is great for a fluid design as it will adjust the layout depending on the available space.
3, Control.Anchor property allows a child control to alter position and size based on the size of the form client area. So you make your control always be a fixed offset from the right or bottom edges.
4, Control.Dock property will position a child control against an edge and the opposite size will automatically be defined by the containing form.
You could put Your controls into tableLayout, and set the Dock property to fill.

Categories