I have a ListView showing all the words from a file, the code is checking these words all the time to see whether they meet certain condition, or so, I would like the checkbox of that list item checked. I have 2 problems here:

1. How can I prevent the user from checking or unckecking the checkboxes? The checkboxes should be only checked/unchecked by the code.

2. When the user double click any list item, it popup an dialog, but the .NET ListView component automatically toggles the checked state of items when you double click on them. How can I keep the ListView checkboxes status as it is when I double click the item?

Any suggestion is appreciated!

Member Avatar for iamthwee

set it t false or something

I would use two images. One of a checked checkbox and one of an unchecked checkbox. Swap the images in your code according to your logic. Clicks will no longer be a problem and the user cannot check/uncheck boxes.

I tried similar way, instead of swapping images, I changed the item's backcolor, there is problem too. For example, one list item meets the condition, so its backcolor is set to certain color by code, but when I double click the item, the backcolor changes to a gray color you see when list item is selected, and it stays in that color until you click on another list item, then the color changes back to the color the code set.

The idea of swapping 2 images might work, but I need to find 2 images small enough to be put beside list items, and I have no idea how to put an image beside and listview item. I will go check it out.

Currently, I set all the items that fit the condition to selected by setting the item's Selected property to true, and my listview enables multiselect. The problem is when the use single click or double click any item, the newly selected item becomes the only one that is selected, how can I keep all the other selected items highlighted as well as the newly selected one or ones?

Member Avatar for iamthwee

Show us your code and possibly a screenshot of your app so far.

Cecilia,

In woodcraft they teach you to go with the grain, otherwise the planer or chisel makes a ragged mess. It's similar in programming. Currently you are fighting against the grain and having a hard time of it.

Try to give us an idea of what you are trying to acheive. By that I mean: What is the purpose of this list view? I am struggling to think of a reason a user would multi select items (CTRL + LEFT CLICK) and then want to double click one to do? ...what?

I can't think of any software I've used that requires me to interact in this manner. It sounds like a battle! The code is selecting items using checkboxes, the user is selecting by clicking. And what is a listview anyway? some 3rd party control? or is it a standard ASP.NET Listbox? if so no you can't bind images to a listbox use a DataList or a GridView they support template columns in which you can include an image control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.