Datagrid and scrolling

S

Stan Guss

My question concerns navigation with the DataGrid on my
Windows Form.

Private Sub btnNext_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnNext.Click
' Move to the next record
NextRecord()
' Highlight the entire row for user feedback.
grdXNew.Select(grdXNew.CurrentCell.RowNumber)

End Sub


' Move the BindingContext Position to the next record.
Public Sub NextRecord()
' The position of the binding context controls
the "current record"
Me.BindingContext(dtXNew).Position += 1
End Sub

The code seems to work fine, except that after
GrdXNew.Select is fired, the Datagrid scrolls back to the
first record. The row that was navigated to is selected,
but if it is not within the bounds of the grid, the row is
not viewable. The user would then have to scroll the
Datagrid to see what row is highlighted. It appears the
behavior is that the grid always scrolls to the top after
a selection is made programmatically.

My question is: Is there a way to maintain the highlighted
row in the viewable area of the grid?

Thank you in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top