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 c开发者_如何学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
精彩评论