Search code examples
c#.netwinformsmultiple-monitors

Persisting form location and size for dual monitors


I have code that persists a forms size and location when it closes, and positions and sizes the form when it loads.

I want to take into account that on load it is possible that the persisted location is outside of the bounds of the screen. Easy to test in a single monitor setup but for multiple monitors, how can I test that. I don't know if the screens are set up horizontally or vertically etc. Somehow I need to determine the combined area of all screens and find out if the forms persisted location is within that area.


Solution

  • Take a look at C#: How to make a form remember its Bounds and WindowState (Taking dual monitor setups into account)