472,981 Members | 1,123 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,981 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 15642
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: 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...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.