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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:22:21+00:00 2026-05-22T18:22:21+00:00

What is a good way to select all or select no items in a

  • 0

What is a good way to select all or select no items in a listview without using:

foreach (ListViewItem item in listView1.Items)
{
 item.Selected = true;
}

or

foreach (ListViewItem item in listView1.Items)
{
 item.Selected = false;
}

I know the underlying Win32 listview common control supports LVM_SETITEMSTATE message which you can use to set the selected state, and by passing -1 as the index it will apply to all items. I’d rather not be PInvoking messages to the control that happens to be behind the .NET Listview control (I don’t want to be a bad developer and rely on undocumented behavior – for when they change it to a fully managed ListView class)

Bump

Pseudo Masochist has the SelectNone case:

ListView1.SelectedItems.Clear(); 

Now just need the SelectAll code

  • 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-22T18:22:21+00:00Added an answer on May 22, 2026 at 6:22 pm

    Wow this is old… 😀

    SELECT ALL

     listView1.BeginUpdate(); 
     foreach (ListViewItem i in listView1.Items)
     {
         i.Selected = true;
     }
     listView1.EndUpdate();
    

    SELECT INVERSE

     listView1.BeginUpdate(); 
     foreach (ListViewItem i in listView1.Items)
     {
         i.Selected = !i.Selected;
     }
     listView1.EndUpdate();
    

    BeginUpdate and EndUpdate are used to disable/enable the control redrawing while its content is being updated… I figure it would select all quicker, since it would refresh only once, and not listView.Items.Count times.

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

Sidebar

Related Questions

Is there a good way to map and ( select or delete_if ) at
Is there a good way to keep keys from conflicting when using the Microsoft
Greetings all, I'm looking for a more efficient way to grab multiple users without
I am using the jQuery Validate plugin, and can never find a good way
Possible Duplicate: Generating all Possible Combinations Is there a good LINQ way to do
I am using Dapper micro-ORM in my project where i want to select all
What is a good way to arrange images in the footer as shown in
Wondering what the best / good way of doing this would be in jQuery.
Question What is a good way of assigning a default value to an optional
Anyone knows a good way to use http live streaming tools on non-Mac platforms?

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.