在使用DataGridView显示来自DataTable的记录时,如果DataTable里的记录太多(上百条),那么用DataGridView查看记录就很不方便,如果能让DataGridView分页显示,每页只显示10条(可以随意规定每页显示的条数),并且配以页面之间的跳转按钮,岂不是方面了许多?现在就来说说我是怎么做到的吧。
我自己编写了一个类用于辅助DataGridView控件的记录分页显示,并提供页面跳转的方法。下面是这个类的源代码:
http://download1.csdn.net/down3/20070610/10102852142.vb
Public Class ClsDataGridViewPage
'每页记录数
Private _RowsPerPage As Integer
'总页数
Private _TotalPage As Integer
'当前页数
Private _curPage As Integer = 0
'要分页的DataGridView
Private _DataGridView As Windows.Forms.DataGridView
'与需要分页显示的的DataView
Private _dv As DataView
'获取与设置每页记录数
Public Property RowsPerPage() As Integer
Get
Return _RowsPerPage
End Get
Set(ByVal value As Integer)
_RowsPerPage = value
End Set
End Property
'获取总页数
Public ReadOnly Property TotalPage() As Integer
Get
Return _TotalPage
End Get
End Property
'获取与设置当前页数
Public Property curPage() As Integer
Get
Return _curPage
End Get
Set(ByVal value As Integer)
_curPage = value
End Set
End Property
&