Question Datagridview cell status

tqmd1

Well-known member
Joined
Dec 5, 2009
Messages
60
Programming Experience
Beginner
Dears



VB.NET:
Private Sub DataGridView1_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
If e.ColumnIndex = 0 And e.RowIndex = 0  Then
            MsgBox("this is first coulmn")
        End IfEnd Sub

IF cursor leaves column 0 and row 0 then it displays msgbox but
I want to check where column 0 and row 0 has value or empty

In case of empty cell it must display msg as
msgbox("this is empty cell")

Please help
 

Attachments

  • cell.JPG
    cell.JPG
    74.6 KB · Views: 36
Here is a starting place for you to check the grid cells on cell leaving

VB.NET:
Private Sub DataGridView1_CellLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave

        If DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value IsNot Nothing Then
            MessageBox.Show(String.Format("Value: {0}", DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString()), "Cell Value")
        End If

End Sub
 
Back
Top