ItemSelectionChanged Event
ItemSelectionChanged Event
Hi
ItemSelectionChanged is rised twice, is this correct?
1) Previous item
2) New item
BR;
Meelis
ItemSelectionChanged is rised twice, is this correct?
1) Previous item
2) New item
BR;
Meelis
Re: ItemSelectionChanged Event
Yes, that's correct, because the selection state of both items changes.
Maybe you are looking for the CaretChanged event?
Maybe you are looking for the CaretChanged event?
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
Ok, the soluton is in ItemSelectionChanged event
If listItem.Selected Then
'Do what is needed
End If
I can't use CaretChangd event, because when i change list item selection in code and the list has no focus then CaretChanged is not rised.
Danke;
Meelis
If listItem.Selected Then
'Do what is needed
End If
I can't use CaretChangd event, because when i change list item selection in code and the list has no focus then CaretChanged is not rised.
Danke;
Meelis
Re: ItemSelectionChanged Event
How do you change the selection in code? Setting the CaretItem property should fire the CaretChanged event.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
Im using your control on my own user control, its like a wraper for yor control with additonal events, properties and methods.
My control has a ListIndex property what i can change in code.
My control has a ListIndex property what i can change in code.
Re: ItemSelectionChanged Event
Well, I assume this ListIndex property is supposed to get/set the caret item, so you should use the CaretItem property. The caret item is the item that has the keyboard focus (if the control has the focus) and usually is selected. Only one item can be the caret item. The ListViewItem.Selected property and the ItemSelectionChanged event have little to do with the caret item. They refer to the item's selection state, i. e. whether it is selected or not. An item is selected if it has a blue background (okay, that's not necessarily correct, but you get the idea). An item that is selected is not necessarily the caret item. In multi-selection mode many items can be selected, but still there's only one caret item.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
Yes and no. When ListView has no focus then i can't use CaretItemWell, I assume this ListIndex property is supposed to get/set the caret item, so you should use the CaretItem property.
Let' say you have texbox, button and listview on the form. Listview has 10 items and textbox has a focus.
When youy click button you must change listviews "listindex" but the listview has no focus then ItemSelectionChanged is rised but CaretChanged not.
I'll try to post a sample with my control

Re: ItemSelectionChanged Event
I just did a test (WIndows 7 x64 with themes):
This code causes the CaretChanged event to be raised, even if the list view doesn't have the focus. The only situation in which the event is not raised, is when item 3 already was the caret item.
Code: Select all
Set ExLvw.CaretItem = ExLvw.ListItems(3)
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
Ok now i understant, we have just different approach 
In my control, when i set the ListIndex property i use;
Public Property Let ListIndex(ByVal value As Long)
If theList.ListItems.Count > 0 Then
If value > theList.ListItems.Count - 1 Then
value = 0
End If
theList.ListItems(value).Selected = True
Let MyListIndex = value
End If
End Property

In my control, when i set the ListIndex property i use;
Public Property Let ListIndex(ByVal value As Long)
If theList.ListItems.Count > 0 Then
If value > theList.ListItems.Count - 1 Then
value = 0
End If
theList.ListItems(value).Selected = True
Let MyListIndex = value
End If
End Property
- Attachments
-
- sample.zip
- (44.35 KiB) Downloaded 966 times
Re: ItemSelectionChanged Event
What is this useful for? You have a property that can be set to exactly 1 list item. It will select this item. What's with the other selected items? Or are you in single selection mode? If you are in single selection mode, why would you want to select an item without making it the caret item?
Of course the CaretChanged event is not raised, if you change an item's selection state, because changing an item's selection state doesn't change the item's caret state.
After trying your sample, I'm convinced more than before that what you really want to use are the CaretChanged event and the CaretItem property.
Of course the CaretChanged event is not raised, if you change an item's selection state, because changing an item's selection state doesn't change the item's caret state.
After trying your sample, I'm convinced more than before that what you really want to use are the CaretChanged event and the CaretItem property.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
Yup, im not using MultiSelect.What is this useful for? You have a property that can be set to exactly 1 list item. It will select this item. What's with the other selected items? Or are you in single selection mode? If you are in single selection mode, why would you want to select an item without making it the caret item?
Of course the CaretChanged event is not raised, if you change an item's selection state, because changing an item's selection state doesn't change the item's caret state.
So better is to use CaretItem?
Re: ItemSelectionChanged Event
Yes, see my edit in the previous post.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: ItemSelectionChanged Event
ok, thank you for your response and for being so patient with me 
Meelis

Meelis
Re: ItemSelectionChanged Event
Hello
Is there a quick way of getting the number of all selected items? I've got over 300.000 items in my Listview and when I want to get the number (in this case in the MouseUp event), it lags a bit before I get it displayed in a Label.
Pete
Is there a quick way of getting the number of all selected items? I've got over 300.000 items in my Listview and when I want to get the number (in this case in the MouseUp event), it lags a bit before I get it displayed in a Label.
Pete
Re: ItemSelectionChanged Event
Hi,
try this:
Regards
TiKu
try this:
Code: Select all
Dim col As ListViewItems
Set col = ExLVwU.ListItems
col.FilterType(FilteredPropertyConstants.fpSelected) = FilterTypeConstants.ftIncluding
col.Filter(FilteredPropertyConstants.fpSelected) = Array(True)
Debug.Print col.Count
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!