How to select items in a ListView control through code?

  • Thread starter Thread starter Andrew
  • Start date Start date
A

Andrew

Hello, friends,

I tried to select all the items using (c#.net):

private void ButtonSelectAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.ListViewPageNumber.Items.Count; i++)
{
this.ListViewPageNumber.Items.Selected = true;
}
}

where the property HideSelection was set to false at design time.

However, I could NOT see the items being selected (normally in blue color).
although I had no problem to select multiple items using mouse or keyboard.
This control is really weired.

Any ideas? Thanks.
 
Hi, friends,

It DID select the items I wanted, and showed the selected items in a light
grey color. However, this color was so light that it was very hard to tell
from form's background color.

Any property that will allow us to change this color? I tried to find it in
propery box, but failed.

Thanks a lot.

This ListView control is really weired.
 
Unfortunately there is no way to change it (unless you want to draw the
items yourself). When the listview has focus they will show up in blue,
otherwise they will be gray.

/claes

Andrew said:
Hi, friends,

It DID select the items I wanted, and showed the selected items in a light
grey color. However, this color was so light that it was very hard to tell
from form's background color.

Any property that will allow us to change this color? I tried to find it
in
propery box, but failed.

Thanks a lot.

This ListView control is really weired.



Andrew said:
Hello, friends,

I tried to select all the items using (c#.net):

private void ButtonSelectAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.ListViewPageNumber.Items.Count; i++)
{
this.ListViewPageNumber.Items.Selected = true;
}
}

where the property HideSelection was set to false at design time.

However, I could NOT see the items being selected (normally in blue
color).
although I had no problem to select multiple items using mouse or
keyboard.
This control is really weired.

Any ideas? Thanks.
 
Back
Top