Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select whole row in Datagrid when user navigate with Keyboard

Status
Not open for further replies.

marcarls

Programmer
Feb 7, 2002
40
SE
Hi!
I have code (see below) to highlight the entire row when any cell of the datagrid is clicked...but I also want to achieve the same thing when the user use the keyboard (tab) to navigate in the datagrid. Can anyone give me a hint on how to solve this ;-)


Private Sub DGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DGrid1.MouseUp
'code to select whole line from the datagrid when any cell is clicked
Dim pt = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = DGrid1.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
DGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)
DGrid1.Select(hti.Row)
End If
End Sub

Regards Maria
 
Use the Select method to highlight the current row in CurrentCellChanged event.

Private Sub DataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid.CurrentCellChanged
DataGrid.Select(DataGrid.CurrentCell.RowNumber)
End Sub

Email: pankajmsm@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top