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.

thanks!
LVL 2
Richard KreidlSoftware DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SawinerCommented:
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;
or
Object value = dataGridView1.Rows[rowIndex].Cells[columnName].Value;

vb.net:
Dim value as Object = dataGridView1.Rows(rowIndex).Cells(columnIndex).Value
or
Dim value as Object = dataGridView1.Rows(rowIndex).Cells(columnName).Value
0
CodeCruiserCommented:
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
         Messagebox.Show("Error")
      End If
    End If
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard KreidlSoftware DeveloperAuthor Commented:
thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.