Show a child form in the centre of Parent form in C#

后端 未结 19 1100
不思量自难忘°
不思量自难忘° 2020-11-28 08:21

I create a new form and call from the parent form as follows:

loginForm = new SubLogin();   
loginForm.Show();

I need to display the chi

19条回答
  •  独厮守ぢ
    2020-11-28 09:06

    The parent probably isn't yet set when you are trying to access it.

    Try this:

    loginForm = new SubLogin();
    loginForm.Show(this);
    loginForm.CenterToParent()
    

提交回复
热议问题