Show Dialog box at center of its parent

后端 未结 5 570
Happy的楠姐
Happy的楠姐 2020-12-28 13:14

It\'s been a mess to show a DialogBox at the center of its parent form. Here is a method to show a dialog.

I am positioning its parent to center but not able to cen

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 13:27

    You might want to check the Form.StartPosition property.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition.aspx

    something along the lines of:

    private void OpenForm(Form parent)
    {
        FormLoading frm = new FormLoading();
        frm.Parent = parent;
        frm.StartPosition = FormStartPosition.CenterParent;
        frm.ShowDialog();
    }
    

    This of course requires setting the form's parent.

提交回复
热议问题