I have implemented data grid view in virtual mode. My data source contains 5k entries. At a time I want to load only 50. Is there a possibility to delete previous row and add a new one on scroll. So that row count remains constant.
Ex.
public void DataGridView1_Scroll(object sender, ScrollEventArgs e)
{
int startIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
int endIndex = startIndex + 50 + 1;
//set datagrid view count to end index
dataGridView1.RowCount = endIndex;
//remove previous rows
startIndex = startIndex - 1;
while (startIndex != -1)
{
dataGridView1.Rows.RemoveAt(startIndex);
startIndex--;
}
}