C # how to implement DataGridView pagination
This article mainly introduces how to achieve DataGridView paging in c #, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
Due to the needs of the project, I wrote a small paging control, as shown below:
Control properties are shown below: four custom properties
Code:
Int pageSize = 10
[Browsable (true)]
[Description ("number of entries per page")]
Public int PageSize
{
Get {return pageSize;}
Set
{
If (pageSize! = value)
{
PageSize = value
This.Invalidate ()
}
}
}
Int pageCount = 10
[Browsable (true)]
[Description ("Total number")]
Public int PageCount
{
Get {return pageCount;}
Set
{
If (pageCount! = value)
{
PageCount = value
This.Invalidate ()
}
}
}
Int pageNumber = 1
[Browsable (true)]
[Description ("Total pages")]
Public int PageNumber
{
Get {return pageNumber;}
Set
{
If (pageNumber! = value)
{
PageNumber = value
This.Invalidate ()
}
}
}
Int pageIndex = 1
[Browsable (true)]
[Description ("current page")]
Public int PageIndex
{
Get {return pageIndex;}
Set
{
If (pageIndex! = value)
{
PageIndex = value
This.Invalidate ()
}
}
}
The control event above the paging control:
There are a lot of paging SQL statements on the Internet, find a matching control, and you can try it. The following picture is a picture of the interface at run time.
Thank you for reading this article carefully. I hope the article "how to achieve DataGridView pagination" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!