Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I want to make size of Window  form responsive for every type of screen resolution. 
I am developing this app on the screen size of 1366 * 768.
But its not working as expected for other screen ressolution like 1420 * 1080

I dont want to use WPF application.

Thanks in advance.


What I have tried:

C#
I have alredy used TableLayOut Panel,FlowlayOut Panel, Dock and Anchor.
But i am not getting expected result.

Can i write my custom code to make window form responsive? If yes, then any tiny help will be more valuable sir.

I dont want to use WPF application.

Thanks in advance.
Posted
Updated 26-Nov-16 0:53am
v2
Comments
Ralf Meier 27-Nov-16 6:33am    
To make a suggestion it is necessary (for me) to know what you exactly try to achieve.
What I have done in the past :
I created a Layout for a Form with all it's controls on it based on a given resolution (normally the smallest one). Now I have a Size-factor depending on the developed Screen-Size and the actual Screen-Size with which you can resize and relocate each control on the form in the Form.OnResize-method.
But ... if you want to do it this way you should know that this cost you some (a lot of) work.
Do you still want to go this way ?

We can't tell you - not because it's a secret, but because we have no idea how your UI is coded, or how it is supposed to look. Much less, what it looks like at different resolutions that means it's "not working as expected". All you can do is look at the two displays and try to work out what is the wrong size, or wrong shape, and concentrate of finding out why.

Normally, these problems come when you reduce the resolution, but that's not the only factor: different PC's can be set to work with different zoom factors to allow text to be bigger on a small screen than it is on a bigger one for example. It may be this that's messing you up.

And pretty often, the fault is that the UI is badly designed: too many controls, too much text, too close together.

But there really isn't anything we can do to fix it for you.
 
Share this answer
 
Comments
Adityakumar2318 28-Nov-16 4:40am    
Thank you so much. Accepted your solution.
OriginalGriff 28-Nov-16 4:55am    
You're welcome!
I have found the best way to solve this type of problem is to make sure every control on the form is anchored or docked - if necessary put group fewer controls together in a panel, then anchor those controls to the panel, and anchor or dock the panel to the form. Breaking the form up into groups of fewer controls makes it easier, but still some fiddling is needed. You can check reasonably well how it will work by just resizing the form manually, and see how the controls all react.
 
Share this answer
 
Comments
Midi_Mick 26-Nov-16 6:57am    
A couple of tricks with this technique. If you anchor both left and right, or both top and bottom, the control will shrink and grow horizontally or vertically respectively relative to the container size and resolution. If you anchor neither left or right, the control will centre itself in its container horizontally. So the trick is to make the containers resize with the form, and the controls to resize within their containers.
Adityakumar2318 28-Nov-16 4:41am    
Thank you so much. Accepted your solution. But i dont want to use anchor and dock property. I have to manage from it code only.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900