I have a small form with measurements Width 391 and Height 160, I want that form when it is executed to appear in the upper right part of the screen (corner of the screen) this regardless of the size of the screen in which it is being executed, taking Note that it can be run on screens of different sizes.
How could I do it?
I do NOT have sample code as I don't know where to start.
Use the event
Load
to change the position, it is the first moment where you will be able to know the real size of the screen (after applying the user configuration and the automatic scale)Source: https://stackoverflow.com/a/7892320/5213794
Edit: I add a small explanation based on Alex Rivas 's comment .
The constructor of
Point
receives the coordinates inx
ey
of where the point will be located (in the case of the example it will be theForm
)Screen.WorkingArea
is a type propertyRectangle
that represents the size of the entire screen.Adding to this, you
Rectangle
have theTop
and propertiesRight
which return the topmost (y) and rightmost (x) coordinate of theRectangle
.In this way, we can know that the form must be at the highest point (
scr.WorkingArea.Top
) and that its location on the axisx
must be the rightmost point (scr.WorkingArea.Right
) minus the width of the form itself (scr.WorkingArea.Right - Width
).I hope that it has been clear!