C# 如何在按钮点击事件中调用load事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16496906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:09:33  来源:igfitidea点击:

How to call load event in button click event

c#winforms

提问by sugashini

How to call load event in button click event I tried by calling Event Handler

如何在我通过调用尝试的按钮单击事件中调用加载事件 Event Handler

this.load += EventHandler(this.Form_Load)//This event called from button click event

But it does not calls the Form_LoadEvent. Could anyone help on this?

但它不会调用Form_Load事件。有人可以帮忙吗?

采纳答案by DatRid

You have to call Form_load.

您必须调用 Form_load。

Form_Load(this, null);

But what you try todo makes no sense for me.

但是你尝试做的事情对我来说毫无意义。

回答by Zeddy

Your best route to resolve this is to place the particular portions of your Form_Load event into a separate sub/function and then to call that function instead.

解决此问题的最佳途径是将 Form_Load 事件的特定部分放入单独的子/函数中,然后改为调用该函数。

Sub Form_Load(sender, e)
  '
  'call to routine
  ProcessFormLoadStuff
  '
End Sub

Sub ProcessFormLoadStuff()
  '
  ' Your code here
  '
End Sub

Sub Button1_Click(sender, e)
  'call to routine
  ProcessFormLoadStuff
End Sub

Finally the way in which you RAISE an event is explained here:

最后,这里解释了您提出事件的方式:

http://msdn.microsoft.com/en-US/library/h7a2kh64(v=VS.80).aspx

http://msdn.microsoft.com/en-US/library/h7a2kh64(v=VS.80).aspx

Whether it is logically acceptable to raise a Form_Load event AFTER the Form has loaded raises some hypothetical issues in correctness. and like many of the other members have stated, its not a usually done thing - meaning its not a text-book method!

在表单加载后引发 Form_Load 事件是否在逻辑上可接受会引发一些假设的正确性问题。就像许多其他成员所说的那样,这不是通常要做的事情 - 这意味着它不是教科书方法!