UserControl加载事件未触发

Cap*_*mic 5 c# events winforms

我有WinForms应用程序.My Form派生类具有UserControl派生类.我只是将几个控件放入一个UserControl中以简化重用.该Load事件UserControl不被解雇.我必须设置一些房产吗?

Ash*_*Ash 10

尝试覆盖UserControl中的OnLoad()方法.来自MSDN:

OnLoad方法还允许派生类在不附加委托的情况下处理事件.这是在派生类中处理事件的首选技术.

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);
}
Run Code Online (Sandbox Code Playgroud)