Winforms Position and Dimension Properties

I am trying to unravel all the properties of the position and size of winforms, and it would be very helpful if there was a comprehensive review explaining the relationship between them. Many of them seem to be functionally equivalent, but I am concerned that I can make some false assumptions.

For reference, I mean properties like Screen.PrimaryScreen.Bounds vs Form.DesktopBounds; Form.ClientRectangle vs Form.DisplayRectangle; Form.left vs Form.Location.X; PointToScreen vs Cursor.Position etc. I am also particularly interested in the effect of multiple monitors on position properties.

If anyone knows about an annotated chart in which all this is done, that would be amazing.

+6
winforms positioning
source share
1 answer

As a partial answer describing the above properties:

  • Screen.PrimaryScreen.Bounds gives the dimensions of the main monitor. On a setting with multiple monitors, which, depending on which screen is set as the primary.
  • Form.DesktopBounds gives you a combined border for the entire “desktop”, which is a virtual canvas that spans all active monitors.
  • Form.ClientRectangle provides the rect area of ​​the client area of ​​the form (the space inside chrome)
  • Form.DisplayRectangle is similar to Form.ClientRectangle , but includes chrome (title and frame around the form)
  • Form.Location.X and Form.Left are actually the same (also applies to vertex and Y), using the top left as 0.0, and incrementing x and y to the right to the right
  • PointToScreen returns the coordinate of the screen, but, apparently, refers to the total area of ​​the desktop; Cursor.Position returns a similar value

If you want to learn more about setting up a screen on the client, check out the Screen class on MSDN . Some interest might be the AllScreens property, which gives you detailed information about the full setup.

Edit

Good - review (simple) ;-) I can be lazy too!

Simple Overview of Position Properties

+17
source share

All Articles