Well, I have a form that I open using:
ShowDialog(this);
I try to change the position of the form using its Location property, but I don’t understand what exactly is this position relative to? I want to open this form below a certain button. So how can this be done?
Thanks.
A Form will expect the co-ordinates relative to the screen’s top-left corner. However, the location of a Control within a Form is relative to the top-left corner of the form†.
Use the Control’s
Locationproperty to find its location, and then callPointToScreenon the Form object to turn it into screen co-ordinates. Then you can position the new form relative to that.For example:
† Actually the top-left corner of the client area of the form.