[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

datagridview selected event vb.net 2008

what is the suitable even to fire code , when user selected Datagridview by mouse click
0
aarontham
Asked:
aarontham
  • 3
  • 2
2 Solutions
 
srikanthreddyn143Commented:
You can use either CellClick/CellDoubleClick events for datagrid view.
Pls look into below link

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24280727.html
0
 
jpaulinoCommented:
What was the problem of RowEnter event ?
0
 
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jpaulinoCommented:
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
            Debug.WriteLine(Now)
        End If
        previousRow = e.RowIndex
    End Sub

Open in new window

0
 
aaronthamAuthor Commented:
Hi jpaulino,

can you explaint if don't do the small walkaround. what will happen?? i just need to know
0
 
jpaulinoCommented:
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.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now