In the MouseUp event for the Datagrid place the following code
miHitRow = dg.CurrentCell. RowNumber
or Call one of the following methods in the Datagrid MouseUp event.
Public Function GetClickedRow(B yVal e As _
System.Windows. Forms.MouseEven tArgs, _
ByRef dbg As DataGrid) As Integer
' this method is called from the mouseup event of a datagrid
' returns the clicked row number (zero based)
Try
Dim pt As Point = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTes tInfo = dbg.HitTest(pt)
Return hti.Row
Catch ex As System.Exceptio n
' ignore the error if the user clicked outside the grid rows,
' e.g., in the header...
End Try
End Function
Public Sub GetClickedCell( ByRef iRow As Integer, _
ByRef iCol As Integer, _
ByRef dbg As DataGrid, _
ByVal e As System.Windows. Forms.MouseEven tArgs)
Try
Dim pt As Point = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTes tInfo = dbg.HitTest(pt)
Catch ex As System.Exceptio n
MsgBox(ex.ToStr ing)
End Try
End Sub
HTH
Les Smith
http://www.knowdotnet.com
"Kshitij" <an*******@disc ussions.microso ft.com> wrote in message
news:B0******** *************** ***********@mic rosoft.com...
Hi,
How do I find the row I clicked on the datagird?
Thanks in advance.