473,379 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 6056
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.