gpt4 book ai didi

c# - 未触发 UserControl Load 事件

转载 作者:太空狗 更新时间:2023-10-29 22:15:13 27 4
gpt4 key购买 nike

我有 WinForms 应用程序。我的 Form 派生类有 UserControl 派生类。我只是将几个控件放入一个 UserControl 中以简化重用。 UserControlLoad 事件未被触发。我必须设置一些属性吗?

最佳答案

尝试覆盖 OnLoad() method在您的用户控件中。来自 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);
}

关于c# - 未触发 UserControl Load 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2220483/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com