all groups > c# > may 2004 >
You're in the

c#

group:

ListView with Checkboxes


ListView with Checkboxes Mike
5/28/2004 11:18:44 PM
c#:

Hi,

When trying to remove the icon from a ListViewItem (see code below), the =
icon does not always disappear. Instead, if I use another index (1, 2, =
etc.) then the correct icon appears. I was thinking that maybe the value =
"-1" is not correct. But what should be the value if someone does not =
want any icon?

private void listView1_ItemCheck(object sender, ItemCheckEventArgs e) =
{
ListViewItem itemChecked =3D this.listView1.Items[e.Index];
if (itemChecked.Checked =3D=3D true)=20
itemChecked.ImageIndex =3D -1;
else=20
itemChecked.ImageIndex =3D 0;
}


Thanks
Re: ListView with Checkboxes Arne Janning
5/29/2004 5:18:25 AM
[quoted text, click to view]

Hi Mike,

I have rebuilt your solution and your code always worked fine on my
machine. -1 in my opinion is correct. Did you try to repaint the control
after changing the ImageIndex?

Cheers

AddThis Social Bookmark Button