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

后端 未结 3 817
挽巷
挽巷 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:36

    Try the StartPosition property on the form.

    0 讨论(0)
  • 2020-12-05 17:56

    I assume you're using a Form, in which case you can use Form.StartPosition enumeration. You can find more about it here and the enumeration behavior here.

    0 讨论(0)
  • 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();
    
    0 讨论(0)
提交回复
热议问题