472,784 Members | 811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

Selecting all the items in a ListView

Hi,

I have a bog-standard ListView control in a v1.1 C# WinForms project, with
three colums, Details View.

There is "Select All" button under the ListView control with the following
code:

foreach(ListViewItem lvi in lvBackupFiles.Items)
{
lvi.Selected = true;
}

This runs OK and correctly sets the Selected property of each ListViewItem
to true.

However, the ListView doesn't update itself until I click on one of its
column headers. I tried surrounding the code with BeginUpdate() and
EndUpdate(), but it still doesn't refresh / repaint.

What am I doing wrong?

Any assistance gratefully received.

Mark
Dec 14 '05 #1
4 6005
you shoudl turn off the HideSelection Property of the listview so that you
can the selection even if LV is not focused.

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> schrieb im Newsbeitrag
news:eX*************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a bog-standard ListView control in a v1.1 C# WinForms project, with
three colums, Details View.

There is "Select All" button under the ListView control with the following
code:

foreach(ListViewItem lvi in lvBackupFiles.Items)
{
lvi.Selected = true;
}

This runs OK and correctly sets the Selected property of each ListViewItem
to true.

However, the ListView doesn't update itself until I click on one of its
column headers. I tried surrounding the code with BeginUpdate() and
EndUpdate(), but it still doesn't refresh / repaint.

What am I doing wrong?

Any assistance gratefully received.

Mark

Dec 14 '05 #2
"cody" <de********@gmx.de> wrote in message
news:eu**************@TK2MSFTNGP14.phx.gbl...
you shoudl turn off the HideSelection Property of the listview so that you
can the selection even if LV is not focused.


Thanks. Is there any way to make the items selected this way (i.e. through
code) have the same colour background as when selected manually using the
mouse?
Dec 14 '05 #3
no

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> schrieb im Newsbeitrag
news:%2***************@TK2MSFTNGP12.phx.gbl...
"cody" <de********@gmx.de> wrote in message
news:eu**************@TK2MSFTNGP14.phx.gbl...
you shoudl turn off the HideSelection Property of the listview so that
you can the selection even if LV is not focused.


Thanks. Is there any way to make the items selected this way (i.e. through
code) have the same colour background as when selected manually using the
mouse?

Dec 14 '05 #4
"cody" <de********@gmx.de> wrote in message
news:ez**************@TK2MSFTNGP14.phx.gbl...
no


Thought not - thanks.
Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: vince | last post by:
I need to programmatically select the first item in a listview before the listview is displayed, so far I'm not having any luck. Here's what I tried in the init for the listview... ...
1
by: Sean Chapman | last post by:
I was wondering how I would go about programmincally selecting a listView item in a listView since the Selected val is read-only. I can't seem to find any other method that will do this for me. I'm...
1
by: Bob Geltz | last post by:
I am able to populate a ListView with several detail lines (several columns). When finished, I would like to pre-select the first item in the list (before the user interacts with the list). This...
4
by: Paddy | last post by:
How do I select a subitem from a listview after clicking on the first column? Couldn't find it in MSDN. Thank you. Paddy.
2
by: David Anderson | last post by:
I'm working on a Windows app that has a ListView containing a bunch of items. When the user clicks on an item, the app displays the item'd details. The user then has the opportunity to edit these...
10
by: Danny Tuppeny | last post by:
Hi All, I'm trying to find the best way to select an item in a ListView using the Virtual mode. My "items" are business classes, and I have a reference to once I want to select (passed from...
3
by: Bry | last post by:
I know you can select a single item in a list view using the following code listView.Items.Selected = true; Is it possible to do this for all items in the listView control without using a...
4
by: Duncan Smith | last post by:
So far, the quikest way I have found to select all items in a list box is to turn off updates, set a wait cusror and then call SetSelected on each item (see below), but it's too slow when the...
1
by: c35tar1 | last post by:
I have a ListView within a dialog. In code the groups are created and items added. Display is 100% correct. The problem is with using Shift to select multiple items in the list. - If you...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.