Selecting all the items in a ListView

M

Mark Rae

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
 
C

cody

you shoudl turn off the HideSelection Property of the listview so that you
can the selection even if LV is not focused.
 
M

Mark Rae

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?
 
C

cody

no

Mark Rae said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top