Selecting all the items in a ListView

  • Thread starter Thread starter Mark Rae
  • Start date Start date
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
 
you shoudl turn off the HideSelection Property of the listview so that you
can the selection even if LV is not focused.
 
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?
 
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?
 
Back
Top