Get the App
SLTechnology News&Howtos  ›  Development  › 

C # how to implement DataGridView pagination

Shulou Source: shulou.com Published: 2022-06-02 11:45:19 09月28日 Update

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!

Tags: Controls articles caches properties following pictures events code values interests at the same time pictures more friends interfaces knowledge editing industry sentences information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB Shulou Information Docker Shulou Tech Info