我在form1中的datagrid的按键上显示form2。这里是form 1代码
Public Shared searchbox As TextBox
Private Sub datagridItems_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles datagridItems.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
If datagridItems.CurrentCell.ColumnIndex = 0 Then
searchbox = datagridItems.CurrentCell.Value
frmitemsearch.ShowDialog()
End If
End If
End Sub
我正在检查表单 2 中搜索框的值是否有任何值,但在表单 2 中它在此行给出错误
Private Sub item_search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim searchstr As String
If IsNothing(frmgrn.searchbox.Text) Then
searchstr = ""
Else
searchstr = frmgrn.searchbox.Text
End If
is nothing fails also I tried this
If String.IsNullOrEmpty(frmgrn.searchbox.text) Then
..它仍然抛出nullexception错误..我对我在这里做错了什么感到困惑......因为我正在检查是否有值然后执行代码。