Question

I have a Windows Mobile project built in C#.

I have a lot of ready made forms having various controls on it, from Listviews to Editfields. When user changes orientation some elements are not refreshing correctly. For example the Listview's columns are same and doesn't accommodate the new screen width change (scrollbars appear or half of the screen is filled).

How do you handle these changes?
Do I need to call for each form these fixes by hand, or I can create some kind of global way to fix this? I would like to go with the simplest method if possible.

I would like to avoid the classic way, to add code to all of my forms. So I am looking for better ways, and I would like to see more ideas.

Was it helpful?

Solution

I'm assuming that most of your controls are using a DockStyle, and that will get you 90% of the way in terms of updating the GUI on orientation changes. For the ListView, you'll have to add in some code.

You can add an event handler on Form.Resize, and there put in code to resize the ListView columns. You can tell portrait vs landscape by comparing width vs height. There's also a way to add an event handler on an actual orientation change, but it's interop and I don't remember the code offhand. Form.Resize should be sufficient for most cases.

You can check out an example here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top