My main form launches another as a modal dialog, using .ShowDialog
. I want to position this based on the mouse-position, but my attempts to call SetDesktopLocation
are having no effect. Is this the right method?
Thanks
In order to set the position of a form programatically before it's visible, you need to set the StartPosition
property to Manual
, then set the Location
property to the desired location.
using(Form toShow = new YourForm())
{
toShow.StartPosition = FormStartPosition.Manual;
toShow.Location = MousePosition;
toShow.ShowDialog();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With