unodgs Messages: 1366 Registered: November 2005 Location: Poland
Ultimate Contributor
Current GridCtrl's search algorithm is indeed slow. I can improve that, but it won't solve your problem anyway. If your database table size grows constantly no matter how searching implementation efficient will be some day you'll hit the wall. And filling grid with data will be taking more and more time as well as memory space. Another thing worth mentioning here is that users are mostly interested in new/fresh data, so loading everything to the memory is in most cases unnecessary.
In my application I use paging control (see the screen-shot). I wrote it myself and if you want I can publish it (but first I need to separate it from my project and write simple example for it). If any button or arrow is pressed I simply generate new query to database that returns a proper result range. Basically this is the same query used to load all data with offset/limit instructions added. Most databases support them. Also if you need sorting you must do it by changing the database query otherwise you will sort only visible part of data and consistency with paging will be lost.
So as you can see I'm doing the same what you were thinking of.
Other solution is to use virtual rows (but GridCtrl doesn't support them) and to load data on the fly as one moves the scrollbar. But that needs some smart cashing strategy, otherwise scrolling experience will be bad. It's very nice solved in xceed grid - http://xceed.com/Grid_WPF_Intro.html. Just run the demo. Maybe I'll add something similar to GridCtrl one day
And of course grid searching will be working on loaded data only (for current page). You have to provide your own searching method to search all database data.