cara membuat paging datagridview

 

Imports System.Data.OleDb

 

Public Class Pagingdatagridview

Dim scrollVal As Integer

 

Private Sub Pagingdatagridview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Me.CenterToScreen()

Call Koneksi()
da = New OleDbDataAdapter("select * from barang", Conn)
ds = New DataSet
da.Fill(ds, scrollVal, Val(TextBox1.Text), 0)
DataGridView1.DataSource = ds.Tables(0)
DataGridView1.ReadOnly = True

cmd = New OleDbCommand("select count(*) from barang", Conn)
rd = cmd.ExecuteReader
rd.Read()
Label2.Text = Label2.Text & rd(0)
End Sub

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <= 0 Then
MsgBox("Tentukan jumlah data")
TextBox1.Focus()
Exit Sub
End If
scrollVal = scrollVal + Val(TextBox1.Text)
ds.Clear()
da.Fill(ds, scrollVal, Val(TextBox1.Text), 0)
End Sub

 

Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

scrollVal = scrollVal - Val(TextBox1.Text)
If scrollVal <= 0 Then
scrollVal = 0
End If
ds.Clear()
da.Fill(ds, scrollVal, Val(TextBox1.Text), 0)

End Sub

 

Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub


End Class