473,405 Members | 2,354 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,405 software developers and data experts.

Selecting all items in a listview

Bry
I know you can select a single item in a list view using the following
code

listView.Items[index].Selected = true;

Is it possible to do this for all items in the listView control without
using a loop?

Thanks.

Nov 17 '05 #1
3 15676
VJ
Not that I know.. but you could extend and write your own ListView control
with a Method that will do this. In the Method you will essentially write a
for loop that will select all items..

VJ

"Bry" <br*********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I know you can select a single item in a list view using the following
code

listView.Items[index].Selected = true;

Is it possible to do this for all items in the listView control without
using a loop?

Thanks.

Nov 17 '05 #2
You could loop through and select each item. However, a method that is a
little faster, especially when you've got a lot of items, is to send the
ListView some key messages. For example...

this.listView1.Focus();
SendKeys.Send("{HOME}");
SendKeys.Send("+{END}");

There was a discussion a while back about this, but related to the ListBox.
http://groups.google.com/group/micro...606fe3ef5805ff

--
Tim Wilson
..NET Compact Framework MVP

"Bry" <br*********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I know you can select a single item in a list view using the following
code

listView.Items[index].Selected = true;

Is it possible to do this for all items in the listView control without
using a loop?

Thanks.

Nov 17 '05 #3


"Tim Wilson" wrote:
You could loop through and select each item. However, a method that is a
little faster, especially when you've got a lot of items, is to send the
ListView some key messages. For example...

this.listView1.Focus();
SendKeys.Send("{HOME}");
SendKeys.Send("+{END}");


You might need to send a Space after the {HOME} to make it work. I'm using
an oaklistview (win32 control pinvoked from user32.dll with support for
images anywhere in the list), and haven't tested with a standard listview,
but in my case without the space to select the first item the 2nd keystroke
sent was processed from the item selected before sending the keys.
Nov 17 '05 #4

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...
4
by: Mark Rae | last post by:
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: ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.