How can I control the location of a dialog when using ShowDialog to display it?

后端 未结 3 832
挽巷
挽巷 2020-12-05 17:18

This is a very trivial problem but I can\'t seem to find a way of solving it. It\'s annoying me because I feel I should know the answer to this, but I\'m either searching fo

3条回答
  •  时光说笑
    2020-12-05 17:57

    You can set the Form.StartPosition property to FormStartPosition.Manual and then set the Form.Location property to your desired location. When you call ShowDialog the form should show up in the desired location.

    MyForm frm = new MyForm();
    frm.StartPosition = FormStartPosition.Manual;
    frm.Location = new Point(10, 10);
    frm.ShowDialog();
    

提交回复
热议问题