【问题标题】:C# - are there any events fired right after loading a form?C# - 加载表单后是否立即触发任何事件?
【发布时间】:2011-10-28 16:22:43
【问题描述】:

我想在用户第一次使用该程序时为他提供使用教程的选项。我尝试在Form.Load 事件中添加它,但在弹出消息框后会显示表单。

这就是我想知道的原因,加载表单后是否会立即触发任何事件?

如果没有,有没有办法在加载后立即执行操作?

【问题讨论】:

    标签: c# winforms events load


    【解决方案1】:

    您应该尝试显示的事件,该事件在表单首次显示后触发。 加载发生在表单显示之前。

    【讨论】:

      【解决方案2】:

      您可以尝试使用Shown 事件,但根据您正在做的事情,这可能有点早,但它确实发生在Load 之后。

      如果您在页面上有任何控件,您可以通过控件GotFocus 事件触发它。如果使用GotFocus 方法,请确保只检查一次。

      MSDNForm.Shown

      MSDN Control.GotFocus

      MSDN Reference to order of events

      System.Windows.Forms.Control.HandleCreated

      System.Windows.Forms.Control.BindingContextChanged

      System.Windows.Forms.Form.Load

      System.Windows.Forms.Control.VisibleChanged

      System.Windows.Forms.Form.Activated

      System.Windows.Forms.Form.Shown

      【讨论】:

        【解决方案3】:

        Shown 事件应该为你做这件事。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-03-29
          • 2021-01-24
          • 2011-10-29
          • 1970-01-01
          • 2013-11-07
          • 1970-01-01
          相关资源
          最近更新 更多