我在VB.NET中做一个Windows Forms项目,但VB.NET对我来说是全新的,我主要是一个C#开发人员.
在C#Windows窗体中,从窗体的/ control的构造函数中调用用户控件的InitializeComponent.当我在VB.NET中创建相同的场景时,我没有得到构造函数,我找不到调用InitializeComponent的位置.
我需要在InitializeComponent之间调用我的代码,并且当控件的Load
事件被引发时,最好仍然在控件的构造函数中.我如何在VB.NET中执行此操作?
Kon*_*nos 11
转到表单中的查看代码,然后从右下拉菜单中选择"新方法".
在那里,您可以看到调用InitializeComponent的位置并插入逻辑.
如果您的表单为空,您的代码应如下所示:
Public Class Form1
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)