473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

ListView with Checkboxes


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 = this.listView1.Items[e.Index];
if (itemChecked.Checked == true)
itemChecked.ImageIndex = -1;
else
itemChecked.ImageIndex = 0;
}
Thanks
Mike
Nov 16 '05 #1
1 1878
Mike wrote:
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 = this.listView1.Items[e.Index];
if (itemChecked.Checked == true)
itemChecked.ImageIndex = -1;
else
itemChecked.ImageIndex = 0;
}


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

Arne Janning
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
1
by: dvestal | last post by:
I have a ListView with checkboxes. I want to remove items when the checkboxes are unchecked, but to do so yields an ArgumentOutOfRangeException. Is there an easy way to get around this? A...
1
by: Carl Johansson | last post by:
I have a virtual ListView (VirtualMode set to true). To make it more convenient for the users of the ListView to select its items, I've set the ListView's CheckBoxes property to true. However, in...
0
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
0
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.