0

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.
    }    
}
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by lolafuertes
0

Every time you need to acces to a listview ítem, the virtual retriever is called, as many times as needed, to obtain the virtual ítems collection for the purpose of the current action being done.
See this info from the library.

Hope this helps

Edited by lolafuertes: Typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.