Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 关于将一个UserControl转换为另一个UserControl_Vb.net_Winforms_User Interface - Fatal编程技术网

Vb.net 关于将一个UserControl转换为另一个UserControl

Vb.net 关于将一个UserControl转换为另一个UserControl,vb.net,winforms,user-interface,Vb.net,Winforms,User Interface,我有一个UserControl,它包含其他Usercontrols,其中有很多函数,有时我需要实例化一个UserControl,比如(Dim x作为新的usercontrolTest),这个函数被启动,我希望函数在我打开UserControl时启动。 由于这个原因,我的项目打开很慢 有没有办法做到这一点?第一个选项是将自定义函数从构造函数移动到每个子控件的加载事件。在这种情况下,只有将控件添加到表单中,自定义函数才会运行 Public Sub New() ' This call is re

我有一个UserControl,它包含其他Usercontrols,其中有很多函数,有时我需要实例化一个UserControl,比如(Dim x作为新的usercontrolTest),这个函数被启动,我希望函数在我打开UserControl时启动。 由于这个原因,我的项目打开很慢


有没有办法做到这一点?

第一个选项是将自定义函数从构造函数移动到每个子控件的加载事件。在这种情况下,只有将控件添加到表单中,自定义函数才会运行

Public Sub New()

  ' This call is required by the designer.
  InitializeComponent()

  ' Add any initialization after the InitializeComponent() call.
  'CustomMethod1()  ' Moved this method to the Load event.

End Sub

Private Sub CustomControl_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  CustomMethod1()
End Sub

第一个选项是将自定义函数从构造函数移动到每个子控件的加载事件。在这种情况下,只有将控件添加到表单中,自定义函数才会运行

Public Sub New()

  ' This call is required by the designer.
  InitializeComponent()

  ' Add any initialization after the InitializeComponent() call.
  'CustomMethod1()  ' Moved this method to the Load event.

End Sub

Private Sub CustomControl_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  CustomMethod1()
End Sub

是否查看了
DesignMode
属性?是否查看了
DesignMode
属性?