471,325 Members | 1,282 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 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 5872
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 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
3 posts views Thread by Bry | last post: by
reply views Thread by rosydwin | last post: by

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.