datagridview selected event 2008

what is the suitable even to fire code , when user selected Datagridview by mouse click
Who is Participating?
srikanthreddyn143Connect With a Mentor Commented:
You can use either CellClick/CellDoubleClick events for datagrid view.
Pls look into below link
Jorge PaulinoIT Pro/DeveloperCommented:
What was the problem of RowEnter event ?
aaronthamAuthor Commented:
HI jpaulino,

The RowEnter event  is not that suitable for me. i have below problem with RowEnter event.
1)it fire when form load.
2)i have a textbox do search this Datagridview1 and display result back to the same Datagridview1. when i use RowEnter this search funtion also got problem.
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
Ok, then use CellClick like srikanthreddyn143 suggested, but you should also do a small walkaround to use only for row change:

    Private previousRow As Integer
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If previousRow <> e.RowIndex Then
            ' your code
        End If
        previousRow = e.RowIndex
    End Sub

Open in new window

aaronthamAuthor Commented:
Hi jpaulino,

can you explaint if don't do the small walkaround. what will happen?? i just need to know
Jorge PaulinoIT Pro/DeveloperCommented:
What happen is that when you select one cell, in the same row, it will always update the second datagridview. Its unnecessary and slows the application.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.