How to Set the Focus on the DataGridView Cell

Good Day:

I am using VB.NET 2005 and the DataGridView.  When the user does not enter data in cell 0 and row(i); I would like to set the focus to the cell with the missing data.  The following code does not work:
            DataGridView1.Rows(i).Cells(0).Selected = True

My entire code is as follows:
  Private Sub DataGridView1_CellLeave(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave

Dim i As Int32
i = e.RowIndex

        If IsDBNull(DataGridView1.Rows(i).Cells(0).Value) Then
            MsgBox("Need Data!")
            DataGridView1.Rows(i).Cells(0).Selected = True
             End If
    End Sub

Any Suggestions?

Thank You,
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.

Try using this

dataGridView1.CurrentCell = dataGridView1[columnIndex, RowIndex];

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
DeniseGoodheartAuthor Commented:
Hello vs1784:

Thanks for your suggestion.  I added a command button called test and put the code behind it.  It works great, but does not work using the DataGridView events.  I will post a new question about this.

Many Thanks,
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
.NET Programming

From novice to tech pro — start learning today.