Resolved check for empty cellsl of a currentrow in DataGridView?

Socarsky

Well-known member
Joined
Dec 27, 2012
Messages
173
Location
Jakarta/Indonesia
Programming Experience
Beginner
How can I check a currentrow cell whether have data or not and it any cell has not data then a messagebox come up to warn that select a non null cell. If not below code occur error as "Uncommitted new row cannot be deleted."
Private Sub MerhabaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MerhabaToolStripMenuItem.Click
        DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
    End Sub
 
Last edited:
How can I check a currentrow cell whether have data or not and it any cell has not data then a messagebox come up to warn that select a non null cell. If not below code occur error as "Uncommitted new row cannot be deleted."
Private Sub MerhabaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MerhabaToolStripMenuItem.Click
        DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
    End Sub

Here is the solution:
[/B]Private Sub MerhabaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MerhabaToolStripMenuItem.Click
    If Not DataGridView1.CurrentRow.IsNewRow Then
         DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
    End If
End Sub[B]

 
Back
Top