Heyya All,
I'm trying to implement Just in time loading into a Virtual Mode DataGridView (Winforms) but either im missing a big piece of the puzzle or its not working....
My table houses approx. 150k Records and takes about 2 minutes to load which is unacceptable.
Code Excerpt below
public partial class Customers : Form
{
private List<Database.Customer> store = new List<Database.Customer>();
public Customers()
{
InitializeComponent();
}
private void Customers_Load(object sender, EventArgs e)
{
store = Global.db.Customers.ToList();
dgv_data.VirtualMode = true;
BindingSource bs = new BindingSource();
bs.DataSource = Global.db.Customers.Local.ToBindingList();
dgv_data.DataSource = bs;
}
private void dgv_data_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
Global.db.SaveChanges();
}
void dgv_data_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
{
e.Value = store[e.RowIndex].GetType().GetProperties()[e.ColumnIndex].GetValue(store[e.RowIndex], null); ;
}
}
Now my understanding is that the CellValueNeeded pulls only the information the DataGridView can display from the database so 30 rows at a time reducing the load time to negligible durations
Can anyone shed some light on why its not working as expected?
The trick was to build a memory cache which displayed 100 or so rows at a time and update when other rows were required.
Data Cache Class (Copy and Paste)