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

  • Home
  • SEARCH
  • 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 3876362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:22:23+00:00 2026-05-19T22:22:23+00:00

Hey all, I have a winforms virtualized Listview that i want to be able

  • 0

Hey all,
I have a winforms virtualized Listview that i want to be able to sort .
I implemented a sorter class that derives from IComparer .
Now, every time i want to sort my listview i do the following :

public void SortMyVirtualListView()
{
    this.VirtualListSize =  0; // set virtual size to 0
    _myInnerList.Sort(_myComparer); // sort the inner listlistview items source)
    this.VirtualListSize = _myInnerList.Count; // re-set the virtual size to items count
}

What i want to make sure is – Is this really how you reset the virtual listview items after a sort? Do I really have to set the virtual list size to 0 and then reset it to the new size ?

It seems like i cannot omit the part about setting the VirtualListSize to zero and then,after re-sorting the underlying list, set the VirtualListSize back to its original value (this.VirtualListSize = _myInnerList.Count).

I could not find any kind of a satisfying code for an optimized (and sortable) virtual list view for winforms .

  • 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-05-19T22:22:23+00:00Added an answer on May 19, 2026 at 10:22 pm

    Is there some performance problem with setting VirtualListSize? This makes sense, because ListView has no idea that your inner list has changed, so you need to tell it somehow.
    If resetting VirtualListSize in this manner is causing performance problems, maybe just redrawing the visible items makes a difference?

    _myInnerList.Sort(_myComparer); // sort the inner listlistview items source)
    int startIndex = this.TopItem == null ? 0 : this.TopItem.Index;
    int endIndex = Math.Min(startIndex + 100, this.VirtualListSize - 1);
    this.RedrawItems(startIndex, endIndex, true);
    

    (Yes, I know, I don’t like the magic number 100 either… 🙂

    Edit: Calling Refresh() after sorting should work too.

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

Sidebar

Related Questions

Hey all, I have created a WinForms to handle Persistence Activities using the Windows
hey all i have a problem in webservice that i am consuming. it takes
Hey all i have 2 dates that i need to see the days that
Hey all i have code to write to an xml doc from asp string
Hey all, I'm writing a C program, and I want to have an array
Hey all - I have an app where I'm authenticating the user. They pass
Hey all, I have something of an interesting requirement for my project. I need
Hey all. I have a server written in java using the ServerSocket and Socket
Hey all I have a large html string like <a style=background: rgb(100, 101, 43)
hey all I have tables with millions of rows in them and some of

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.