Reputation: 810
I need to add on my software a new monitor with different resolution than previous one but I still need support for both.
I was thinking about include a switch case on every FORM LOAD event and, based on screen resolution, then change sizes of all buttons, forms, objects in general contained in the form.
Select case Resolution
case 800x480
resizes my controls...
case 1024x768
resizes my controls...
end select
The application will run on windows ce 6 with compact framework 3.5
Question is:
Is there a smarter way to handle different resolutions in .NET?
Upvotes: 3
Views: 1243
Reputation: 10855
Go with Anchor and Dock if they work for you, as suggested by Reed.
That being said, if your screens are really complex or you deal with drastically different device form-factors such that a simple resizing of your controls won't suffice, I suggest structuring your solution/code such that you can develop seperate screens for each form factor and placing them in satelite assemblies that are loaded at runtime. Your logic must reside outside the forms to do this, but it really should anyway.
Upvotes: 1
Reputation: 564403
Yes, though it depends on which user interface framework you're using.
The goal is to design your interfaces to expand reasonably at different resolutions. This can be done in Windows Forms, for example, by taking advantage of the Anchor and Dock properties, instead of using absolute positioning and sizing. This allows the items to "move" and "scale" appropriate as the window sizes change.
Upvotes: 2