How to go to next or previous in a DataGrid

  • Thread starter Thread starter S.Hoa
  • Start date Start date
S

S.Hoa

Hello
I want to have a button so that when I click, I can go to the next record
in a DataGrid
Thank you
 
Hi,

Use the currencymanager for that.

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNext.Click

Dim cm As CurrencyManager = CType(Me.BindingContext(DataGrid1.DataSource),
CurrencyManager)

Dim intPos As Integer = cm.Position

If intPos < cm.Count - 1 Then

cm.Position = intPos + 1

End If

End Sub

Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrev.Click

Dim cm As CurrencyManager = CType(Me.BindingContext(DataGrid1.DataSource),
CurrencyManager)

Dim intPos As Integer = cm.Position

If intPos > 0 Then

cm.Position = intPos - 1

End If

End Sub



Ken

----------------------------------

Hello
I want to have a button so that when I click, I can go to the next record
in a DataGrid
Thank you
 

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

Back
Top