By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

How to go to next or previous in a DataGrid

P: n/a
Hello
I want to have a button so that when I click, I can go to the next record
in a DataGrid
Thank you
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

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

"S.Hoa" <so*@slingshot.co.nz> wrote in message
news:1096544677.427214@ftpsrv1...
Hello
I want to have a button so that when I click, I can go to the next record
in a DataGrid
Thank you

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.