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 8660699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:19:14+00:00 2026-06-12T16:19:14+00:00

Is it possible to sort all ListViewGroups of a Windows Forms ListView alphabetically at

  • 0

Is it possible to sort all ListViewGroups of a Windows Forms ListView alphabetically at runtime?

Or do I have to manually implement sorting when I’m adding a group (using the “Insert” method of the ListViewGroupCollection)? If this is the case, can someone give me an idea how to do this?

  • 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-12T16:19:15+00:00Added an answer on June 12, 2026 at 4:19 pm

    In WinForms ListView, you have to do the sorting manually:

    ListViewGroup[] groups = new ListViewGroup[this.listView1.Groups.Count];
    
    this.listView1.Groups.CopyTo(groups, 0);
    
    Array.Sort(groups, new GroupComparer());
    
    this.listView1.BeginUpdate();
    this.listView1.Groups.Clear();
    this.listView1.Groups.AddRange(groups);
    this.listView1.EndUpdate();
    
    ...
    
    class GroupComparer : IComparer
    {
        public int Compare(object objA, object objB)
        {
            return ((ListViewGroup)objA).Header.CompareTo(((ListViewGroup)objB).Header);
        }
    }
    

    Groups in .NET ListView are quite nasty – they look and behave like a mix between old Win32 ListView and Windows Explorer…

    So I would recommend you Better ListView component which supports sorting groups out of the box:

    this.betterListView1.Groups.Sort(new GroupComparer());
    
    ...
    
    class GroupComparer : IComparer<BetterListViewGroup>
    {
        public int Compare(BetterListViewGroup groupA, BetterListViewGroup groupB)
        {
            return groupA.Header.CompareTo(groupB.Header);
        }
    }
    

    Furthermore, the groups look and behave just like in Windows Explorer, are collapsible and no flickering happens even when you sort them.

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

Sidebar

Related Questions

I using jquery sorting ( http://jqueryui.com/demos/sortable/ ). Is it possible to sort (move list)
Possible Duplicate: php sort array by sub-value I have a multidimensional array like the
Possible Duplicate: Natural Sort Order in C# I have a list with a lot
I have a number of very long arrays. No run-time sort is possible. It
I was just wondering, is it at all possible to create sort of like
Possible Duplicate: Finding all cycles in graph I have a task I've been wrapping
In building an Excel workbook with VB.Net, is it possible to sort all the
I would like to know if it is possible to have sort of compile
I was curious if it's possible to implement a sort of variadic version of
I have a pathological issue with SQL, so I usually sort all of my

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.