UserControl Load event not fired

前端 未结 3 1809
名媛妹妹
名媛妹妹 2020-12-06 20:11

I have WinForms application. My Form derived class has UserControl derived class. I simply put several controls into one UserControl to simplify reuse. The Load

3条回答
  •  渐次进展
    2020-12-06 20:41

    Try overriding the OnLoad() method in your UserControl. From MSDN:

    The OnLoad method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

    protected override void OnLoad(EventArgs e)
    {
        //Your code to run on load goes here 
    
        // Call the base class OnLoad to ensure any delegate event handlers are still callled
       base.OnLoad(e);
    }
    

提交回复
热议问题