How can I load data in a DataGridView as scrolling?

Good day! There is data about 50,000 rows which should be displayed in datagridview. If all load then the performance decreases and eats too much memory. Decided to load the data in pieces. But there are moments that do not like. For example, load the next chunk of data when scroll reaches the end and remove the previous data and here is an embarrassing moment. Scrolling jumps up the data immediately changes and becomes unclear what is where. Maybe there are some beautiful solutions or where to read? Yes, saw in 1C which is the same (or similar) is done only he is scrolling in the middle and comes to the end when all data is loaded. How can you do such a thing?
June 26th 19 at 14:15
2 answers
June 26th 19 at 14:17
Virtual mode DataGridView to help you.
In General, that's why the user interface of 50K rows. All the same to him as it is not necessary. And overhead costs a lot of memory, disk, and network exchange (if data is retrieved from a remote database).
Show the user only what he needs at the moment or use the pagination.
Read. In that case )) I Want to show it to pieces. This list may need only one. Most users do not work with the filters and they need all the data in a list (and they are not trained clumsy people and tells them it's a waste of words in the wind )) ). Now the data is loaded in advance in memory and takes over 100 MB and this is only for production (and the problems of this bunch). - rowland_Hagen commented on June 26th 19 at 14:20
June 26th 19 at 14:19
: You can just create a page, for example, mytable.xaml. In mytable.xaml.cs take a parameter with the page number from the frame:
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
 int page = (int) e.ExtraData;

There starts the selection from the database, for example MySQL code would look like this:
MySqlCommand cmd = (your variable connection).CreateCommand();
cmd.CommandText = "SELECT * FROM table ORDER BY id ASC LIMIT 10,@pagenum";
int pagenum = page*10-1;
MySqlDataReader result = cmd.ExecuteReader();
// Add the row to the table. Working with them on the type of the result.ColumnName, result.ColumnInfo etc.
// int page - the page number of the example, reception of a parameter passed to a frame.
// int pagenum - multiply the page number by 10 and move the ID 1 to the beginning.

To use the upload (append content when scrolling) is impractical, especially if I have to then scroll up. I myself am a newbie, so an example may be rough and uncouth.)

Find more questions by tags ADO.NETC#