简体   繁体   中英

How to implement paging function in the datagrid when using data binding (winforms)?

I use data binding to control the datagrid, which connect to database table directly, what I want to do now is to implement the pager function on the datagrid, which I can only load 20 records from Database into memory, and display them. What do I know now is the the data binding will load all the records into database and then do some filtering and display in the control.. any suggestion ?

Basicaly you have to run your datagrid in virtual mode, tell the grid how many rows there are in your recordset and then react to the CellValueNeeded-event. We implemented caching follwing this example on msdn .

You need to load 20 records at a time in your data source, ie you have to implement paging yourself. Each time the user requests a new page, you read the new set of records.

On the SQL side, 'sql paging' will get you lots of results from your favorite search engine and here is an example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM