假设下面的代码:
BeginInvoke(New Action(Sub()
Dim i As Integer = 0
Do While i < selectedRows.Count
myGridView.SelectRow(myGridView.GetRowHandle(selectedRows(i)))
i += 1
Loop
End Sub))
任何人都能解释一下为什么如果我用这样的With语句写它:
With myGridView
BeginInvoke(New Action(Sub()
Dim i As Integer = 0
Do While i < selectedRows.Count
.SelectRow(.GetRowHandle(selectedRows(i)))
i += 1
Loop
End Sub))
End With
调试器抛出一个空引用异常,我无法解释