Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Datagrid View selection changed event problem

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Visual Basic.NET
5 Comments1 Solution802 ViewsLast Modified:
vb.net 2003
sql express 2005

What I have :
My users have a textbox to type in a search string
They press the <Enter> button and the datagrid shows the results.

I have 3 additional  textboxes that show the current datagrid row as they scroll in the datagrid itself.

If the user want to do another search. They go back into the searcbox and type in a new criteria.
Problem:  In order to avid a  null error on this line.
Me.DataGridView1.CurrentRow.Cells(0).Value   <-------------  
I cheated and use the on "error resume next" opt out.

Question: Is there a better way to capture the Null Value error that generates because of the "SelectionChangted"  event ?


Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
        On Error Resume Next
        Me.TextBox3.Text = Me.DataGridView1.CurrentRow.Cells(0).Value
        Me.TextBox4.Text = Me.DataGridView1.CurrentRow.Cells(1).Value
        Me.TextBox5.Text = Me.DataGridView1.CurrentRow.Cells(2).Value

    End Sub
Avatar of Shaun Kline
Shaun KlineFlag of United States of America imageLead Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers