こんにちは、行を変更したときに変更を保存するための以下のコードがあります。しかし、私にとって重要なことは、1 つのセル「説明列」が空の場合は変更を保存しないことです。メッセージ ボックスを表示するには、このコードにどのように追加すればよいですか。「説明が空または null の場合は保存できません」ありがとうロブ
' We need an indicator to know when we need to update the source database
Dim UpdatePending As Boolean = False
Private Sub ExampleBindingSource_ListChanged(ByVal sender As Object, _
ByVal e As System.ComponentModel.ListChangedEventArgs) _
Handles ExampleBindingSource.ListChanged
' Whenever there is an update, note that a change is pending.
'
' ListChanged does not fire when moving within a row, so this will not
' mark updates until done with the row. (Here "done" could mean moving
' to another row or closing the form.)
If Me.ExampleDataSet.HasChanges Then
Me.UpdatePending = True
End If
End Sub
Private Sub DataGridView1_RowValidated(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles DataGridView1.RowValidated
' The RowValidated event occurs after
' BindingSource_*Changed operations, which
' makes it a good place to update our source database.
' However, this event fires at a number
' of times when we don't have pending updates.
' That's why we need the UpdatePending indicator
' to tell us whether to do anything.
' If we have an update pending, copy it to the source database
If UpdatePending Then
Me.ExampleTableAdapter.Update(Me.ExampleDataSet.Example)
Me.UpdatePending = False
End If
End Sub