When the ListView is in virtual mode, you cannot add items to the ListView items collection. Use the VirtualListSize property instead to change the size of the ListView items collection.
Would you please guide me ?
Thanks.
Last edited by M-Dayyan; January 16th, 2010 at 05:30 AM.
In order to use virtual mode, you must handle the RetrieveVirtualItem event, which is raised every time the ListView requires an item. This event handler should create the ListViewItem object that belongs at the specified index.
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
read my first response here, this is the second post (#2) you're even doing the same. I don't understand where is the problem? have you not subscribed to the event?
Code:
listView1.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(this.listView1_RetrieveVirtualItem)
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
Thanks memeloo.
I have done it too !!!
I think you couldn't understand me well ! let's explain more :
I'm working with SQL to LINQ,
before I use ListView in VirtulMode, whenever I was getting a query with LINQ , I added them to the ListView with a loop :
I do understand. you do not populate the entire list in a loop like before. it is automatically populated as needed in the listView1_RetrieveVirtualItem event handler. there you must put the code that retrieves the right items.
you can cache the result from the query so that you don't have to run the query every time.
Last edited by memeloo; January 16th, 2010 at 06:08 AM.
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
no. you get the e.ItemIndex which corresponds to the listView's item that will be displayed next.
I don't know what your query result looks like, but you have to do something like this:
Code:
void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
// var query = from ... // run the query here or cache it somewhere else and just use the cache
e.Item = new ListViewItem(query[e.ItemIndex]);
}
but probably this won't work. your query result has to be some array or a list and you must get the item at the e.ItemIndex position.
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
Bookmarks