Groups | Blog | Home
all groups > vb.net > september 2004 >

vb.net : How to go to next or previous in a DataGrid


Ken Tucker [MVP]
9/30/2004 7:53:31 AM
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

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

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


S.Hoa
9/30/2004 11:44:01 PM
Hello
I want to have a button so that when I click, I can go to the next record
in a DataGrid
Thank you

AddThis Social Bookmark Button