Vb.net 关于将一个UserControl转换为另一个UserControl
我有一个UserControl,它包含其他Usercontrols,其中有很多函数,有时我需要实例化一个UserControl,比如(Dim x作为新的usercontrolTest),这个函数被启动,我希望函数在我打开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
有没有办法做到这一点?第一个选项是将自定义函数从构造函数移动到每个子控件的加载事件。在这种情况下,只有将控件添加到表单中,自定义函数才会运行
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
属性?