How to check if a cell in a datagrid has data within it?

I have a Datagrid with 5 columns with many rows.

How would check to see if  a cell in the 4th column has data within it?

Basically, the user would do a mouse click on a blank cell from the 4th column and it would then insert the system time. Now, if user would try to click the same cell again, I would like an alert to popup  to inform them that they can't update that cell.

Richard KreidlSoftware DeveloperAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

CodeCruiserConnect With a Mentor Commented:
Try IsDBNull function or IsNothing Function

If Not IsDBNull(dgv.Rows(3).Cells(4).Value) Then
   If Not IsNothing(dgv.Rows(3).Cells(4).Value) Then
      If Not String.IsNullOrEmpty(dgv.Rows(3).Cells(4).Value) Then
      End If
    End If
End If
the data from the cells can be obtained with row and column. Do note however data grid view prefer to go by row, meaning you first need to know the row, and then the column. You can also use a column name instead of index, however you need an index for the row:

Object value = dataGridView1.Rows[rowIndex].Cells[columnIndex].Value;
Object value = dataGridView1.Rows[rowIndex].Cells[columnName].Value;
Dim value as Object = dataGridView1.Rows(rowIndex).Cells(columnIndex).Value
Dim value as Object = dataGridView1.Rows(rowIndex).Cells(columnName).Value
Richard KreidlSoftware DeveloperAuthor Commented:
All Courses

From novice to tech pro — start learning today.