question

Booney-3048 avatar image
1 Vote"
Booney-3048 asked Dionfitzgerald-3257 commented

How to search winform and use paging

Can someone show example or give direction on how to search a WinForms and have a paging button .
I will search by date and could have several records for the same date so I need to page through them.
I don't have a datagridview it retrieving from a SQLITE database.

dotnet-csharpwindows-formsdotnet-sqlite
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

One more thing on paging and searching, a robust solution is best done with a custom grid such as the following from Progress/Telerik which is a pay for library. There are other pay for libraries such as this one which I can vouch for as I never used it like the first one.

For many there seems to be an aversion to using pay for library but a consideration is, how much of a developer's time might be spent on coding this with no expertise against the cost of the library?


0 Votes 0 ·
karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered Dionfitzgerald-3257 commented

High level something like this

 SELECT 'your colmns' FROM your table LIMIT 10 OFFSET 10;

In code you would have a variable for how many records to return e.g. pageSize then an offset, where to start with. So for instance there are 100 records, page size is 10. You would get the first 10 records then next time starting at positon 11 and get next ten records etc.

  $"SELECT 'your colmns' FROM your table LIMIT {pageSize} OFFSET {offset};";

Just coded something very similar last night for a C#8 features, might give you ideas.

Anytime I've needed pagination it's been with a 3rd product so nothing to show code-wise.



90990-kpmvp.png



kpmvp.png (2.0 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Link not working

0 Votes 0 ·

I don't see the point in posting incomplete code? It does not output anywhere!

0 Votes 0 ·
Show more comments
DuaneArnold-0443 avatar image
1 Vote"
DuaneArnold-0443 answered

I don't know how you expect to do paging without some kind of Windows form control like a grid.

https://www.codeproject.com/Articles/16303/DataGrid-Paging-C-Windows-Forms

https://docs.microsoft.com/en-us/visualstudio/data-tools/create-a-windows-form-to-search-data?view=vs-2019

You should be able to tie it altogether and come up with something.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.