所以我有这个代码的形式叫做MyMenuForm
。
Public Class MyMenuForm
Public Sub LoadForm(sender As Object, e As EventArgs)
DataGrid.DataSource = DataGridTable
DataGridTable.Columns.Add("Name", GetType(String))
DataGridTable.Columns.Add("Verison", GetType(String))
DataGridTable.Columns.Add("Compile", GetType(Button))
DataGridTable.Columns.Add("Location", GetType(String))
DataGridTable.Columns.Add("CompileLoc", GetType(String))
End Sub
Public DataGridTable As DataTable
End Class
我希望能够DataGridTable
从名为AddForm
.
Public Class AddForm
Public Sub Add_Click(sender As Object, e As EventArgs) Handles AddButton.Click
MyMenuForm.DataGridTable.Rows.Add(NameBox(), VersionBox(), "Compile", LocationBox(), CompileBox())
End Sub
End Class
当我单击AddButton
按钮时,我收到错误
Additional information: Object reference not set to an instance of an object.
有谁知道为什么会发生这种情况或我该如何解决?我已经在我的能力范围内进行了谷歌搜索,但没有找到解决方案。请帮忙。