発端→解決
DataGridViewでチェックが変更されたのを知りたい。
↓
ググって発見。
DataGridViewの列にチェックボックスを表示する .NET Tips C#, VB.NET
・チェックボックスにチェックが付けられた(あるいはチェックが外された)ことを知る
https://dobon.net/vb/dotnet/datagridview/datagridviewcheckboxcolumn.html#section3
↓
スペースキーでチェックボックスの値を変えると例外が出る。
↓
ググって発見。デリゲートでCommitEditを遅延させる必要があるらしい。
https://connect.microsoft.com/VisualStudio/feedback/details/780347/nullreferenceexception-in-notifymassclient-after-checking-unchecking-a-checkbox-in-datagridview-with-spacebar
↓
C#だったのでVB.NETへ変換。
Delegate Sub InvokeDelegate()
Private Sub MyDelegate()
Me.DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
End Sub
Private Sub DataGridView1_CurrentCellDirtyStateChanged(ByVal _sender As Object, ByVal _e As EventArgs)
If Me.DataGridView1.CurrentCellAddress.X = 0 AndAlso
Me.DataGridView1.IsCurrentCellDirty Then
'コミットする
BeginInvoke(New InvokeDelegate(AddressOf MyDelegate))
End If
End Sub