I am using LIstView control in virtual mode with the property listView.VirtualMode=True and I have subscribed the event listView1_RetrieveVirtualItem(). But this event is being called many times for each item. What is the reason or How can I prevent RetrieveVirtualItem() from executing many times?
Please check the below code.
public class Form1 : Form
{
public Form1()
{
listView1.VirtualMode = true;
listView1.VirtualListSize = 100000;
listView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(listView1_RetrieveVirtualItem);
}
private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
ListViewItem itm=new ListViewItem(comboBOx.Items[e.ItemIndex].ToString());
e.Item = itm;
// For each visibile item this code is executed many time.
}
}