how parentForm Reference is null?

前端 未结 2 682
一整个雨季
一整个雨季 2021-01-18 20:42

I have an application in which i have added a usercontrol on the form. When i check this.parentForm in the userControl constructor it gives a null reference

2条回答
  •  天命终不由人
    2021-01-18 21:35

    for what did you added this line no need actually, remove this line

     if (this.ParentForm != null)//ParentReference is null
    
    public UserControl1()
            {
                InitializeComponent();            
                MessageBox.Show("Hi");//Does Not get Called
    
            }
    

提交回复
热议问题