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!

Autoselect first row in datagrid

Status
Not open for further replies.

RocAFella2007

Technical User
Mar 21, 2007
45
GB
when the form loads. Could someone please offer me some help I have spent hours and hours trying to find a solution but its just not happening. I have tried

dgContacts.CurrentRowIndex = 0

and

dgcontacts.SelectedIndex = 0

But its just not working, any herlp or suggestions please?
 
Its fine I have found a way of doing it. But it was thru a dataset
 
If you'd like to enlighten the rest of us on what "it" was, please feel free to do so at any time. :)
 
Not quite what you were looking for, but close. Try something like this...
'attach to the mouse up event
'this will highlight an entire row,
'regardless of where in the row the user clicked

Dim pt = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = dgContacts.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
dgContacts.CurrentCell = New DataGridCell(hti.Row, hti.Column)
dgContacts.Select(hti.Row)
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top