470,573 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

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 15487
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sean Chapman | last post: by
1 post views Thread by Bob Geltz | last post: by
4 posts views Thread by Paddy | last post: by
2 posts views Thread by David Anderson | last post: by
4 posts views Thread by Mark Rae | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.