Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:32:36+00:00 2026-06-03T23:32:36+00:00

With respect to a Virtual ListView control in a Winforms App, what are ALL

  • 0

With respect to a Virtual ListView control in a Winforms App, what are ALL the functions of RetrieveVirtualItem event?

Scenario: There is a Dictionary object which acts as my ListView cache. And its items are displayed on the ListView. On click of a column, the cache dictionary is sorted in memory and the ListView is Refresh()ed. The effect on UI, the ListView is sorted well. 🙂

But I want to understand what the role of RetrieveVirtualItem Event is, which gets triggered on Refresh().

In the RetrieveVirtualItem event handler [ Someone else’s code, 🙁 ], following are done:

  1. Based on RetrieveVirtualItemEventArgs.ItemIndex, get the message from Cache
  2. Set RetrieveVirtualItemEventArgs.Item = retreived item above

It appears that what’s done in the event handler is important because, if I take it out, ListView cries. What is the significance of this event?

EDIT
Or let me re-phrase the question… My concern is, Why, after Sorting (and RetrieveVirtualItem event handler), the selected item remains at the location where it was before sorting. I.e, If I select item #5 and sort, and if sorting makes this item as the last item, I would prefer the LAST item to be selected after Sort. But in my case 5th item is selected after sort. So what is the default behavior of RetrieveVirtualItem WRT selected item?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:32:38+00:00Added an answer on June 3, 2026 at 11:32 pm

    Virtual listviews only deal with indices. So, if the 5th item is selected before the sort, the 5th item will still be selected after the sort. The control itself has no way of knowing that the data that used to be on the 5th row is now on the first row.

    You will have to program that for yourself in your sorting method:

    1. remember which items were selected (remember: you can’t use SelectedItems property when in virtual mode)
    2. do the sort
    3. find the indices of the previously selected item now live
    4. select those indices

    You can see all this in action in ObjectListView — a wrapper around a standard .NET ListView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the mouse position with respect to the control in which
Which is better in respect to performance and memory utilization? // + Operator oMessage.Subject
Is there a way to autoincrement a field with respect to the previous one...e.g
With respect to an array containing a lot of duplicate elements, is there any
This question is with respect to local host on my PC which is shared
Are there any limitations with respect to developing ASP.NET and WPF apps using VS
Is there any best practice with respect to coding style with respect to explicit
How can I make PHPUnit respect __autoload functions? For example, I have these three
With respect to coding standards, speed, and efficiency, which of the following is a
With respect to C# 4.0, which of these two is the correct term: Named

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.