【问题标题】:How to open up a form from another form in VB.NET?如何在 VB.NET 中从另一个窗体打开一个窗体?
【发布时间】:2013-12-16 22:36:26
【问题描述】:

我认为这很容易。我没有太多地使用VB.NET,我试图通过单击按钮打开一个表单。表单不会显示,我收到一个空异常错误。

代码有什么问题?

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    Dim A
    A = AboutBox1
    A.Show()
End Sub

【问题讨论】:

  • Dim A As New AboutBox1 // A.ShowDialog
  • CTRL+G 将打开编辑器的插入图像部分,以便您可以包含图像。

标签: vb.net


【解决方案1】:
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) _
                          Handles Button3.Click

    Dim box = New AboutBox1()
    box.Show()

End Sub

【讨论】:

  • 应该,是的。这是MSDN
  • 有什么想法会在调用表单下方打开新表单吗?
  • 我将 form.show() 更改为 form.show(me),它现在按预期工作。
【解决方案2】:

你也可以使用showdialog

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) _
                      Handles Button3.Click

     dim mydialogbox as new aboutbox1
     aboutbox1.showdialog()

End Sub

【讨论】:

  • 如果我希望它是任何形式怎么办?也许是我自己创造的?
【解决方案3】:

你可以使用:

Dim MyForm As New Form1
MyForm.Show()

或者更确切地说:

MyForm.ShowDialog()

将表单作为对话框打开,以确保用户与新表单交互或关闭它。

【讨论】:

    【解决方案4】:

    您可能希望首先在解决方案资源管理器和代码文件类型中右键单击项目来创建一个对话框

    dialogue1.show()
    

    就是这样!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多