我有一个Module.cs,我想在单击按钮时运行模块内部的void。我怎样称呼虚空?
Module.cs:
public void CreateInventorApplication()
{
// İnventorün Yüklenmesini Bekle
while (!InvApp.Ready)
{
System.Windows.Forms.Application.DoEvents();
}
DefaultCaption = InvApp.Caption;
InvApp.Visible = true;
WatchTimer.Enabled = true;
StatusType = StatusTypeEnum.Online;
StatusMessage = "InventorPreparing";
}
Form1.cs:
private void button1_Click(object sender, EventArgs e)
{
}
您的void需要公开,否则其他类和文件将无法访问。
public void button1_Click(object sender, EventArgs e)
{
}
您在措辞上有些含糊,但我假设您想在单击按钮时运行“ CreateInventorApplication”。
您的click事件方法需要引用您的Module类的实例。您将需要创建Module的实例,使该实例可用于button1_Click方法,然后对其进行调用。你可以做这样的事情。
private void button1_Click(object sender, EventArgs e)
{
// Create an instance of the Module class that the button click event can access.
Module myModule = new Module();
// Call the void function using the instance we just created.
myModule.CreateInventorApplication();
}