all selected items unchecked when unchecking other items in listview
Hi guys...
Code:
For Each i As ListViewItem In Me.lvSent.Items
If i.Checked = True Then
i.Selected = True
Else
i.Selected = False
End If
Next
Using that code I can select items in my listview but when I unchecked one selected item, It unchecked all selected items.
thanks
Re: all selected items unchecked when unchecking other items in listview
I don't see anything in that code that is going to check or uncheck any items. That code is going to select all checked items and unselect all unchecked items. If you're seeing items get unchecked then that must be happening elsewhere.
Re: all selected items unchecked when unchecking other items in listview
wrong question please delete
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
chrisTemper
I can select items in my listview but when I unchecked one selected item, It unchecked all selected items.
Isn't that the way the control is supposed to work, otherwise how could the end user check or uncheck multiple items at the same time?
So I think you'll need to deselect the items first, then you can check/uncheck one item only, at least that is the way it works as an end user, I didn't actually try any code.
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
Edgemeal
Isn't that the way the control is supposed to work, otherwise how could the end user check or uncheck multiple items at the same time?
So I think you'll need to deselect the items first, then you can check/uncheck one item only, at least that is the way it works as an end user, I didn't actually try any code.
Hmmm... I wasn't aware of that. I just tested with a new project and no code and it does indeed behave that way.
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
Edgemeal
Isn't that the way the control is supposed to work, otherwise how could the end user check or uncheck multiple items at the same time?
So I think you'll need to deselect the items first, then you can check/uncheck one item only, at least that is the way it works as an end user, I didn't actually try any code.
yes sir... sorry I forgot to ask... how can I unchecked selected Items without automatically unchecking other items too?... That code works fine for me by selecting only... thank you sir...
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
jmcilhinney
That code is going to select all checked items and unselect all unchecked items.
Yes sir... It is only working in cheking multiple items.. but when I unchecked one checkbox all items were unselected. What I want is even if I unchecked other items. other items will still remains checked
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
chrisTemper
Yes sir... It is only working in cheking multiple items.. but when I unchecked one checkbox all items were unselected. What I want is even if I unchecked other items. other items will still remains checked
As has already been said, that's how a ListView works. If you don;t want to uncheck multiple items then don't select multiple items. If you're really determined to make it appear to the user that it doesn't work that way when you uncheck an item in code then you could first add all the selected items to a list of your own, unselect them all, uncheck your item and then reselect the items in your list.
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
jmcilhinney
As has already been said, that's how a ListView works. If you don;t want to uncheck multiple items then don't select multiple items. If you're really determined to make it appear to the user that it doesn't work that way when you uncheck an item in code then you could first add all the selected items to a list of your own, unselect them all, uncheck your item and then reselect the items in your list.
okay sir thanks... so it is not possible for a listview to do multiple uncheck.... But is it possible in datagridview?...
Re: all selected items unchecked when unchecking other items in listview
Quote:
Originally Posted by
chrisTemper
okay sir thanks... so it is not possible for a listview to do multiple uncheck.... But is it possible in datagridview?...
Unchecking a cell in a DataGridView will have no implicit effect on any other rows.