All the sample code I see allows you to check a row object. How does one get the entire list of checked objects? Surely someone knows how? Even a little hint may help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When using a TreeListView with HierarchicalCheckboxes = true, CheckedObjects doesn't include child objects that were never made visible. How do you include the child objects in the list that have not been expanded in the tree by the user? (Once expanded, they are included.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When using a TreeListView with HierarchicalCheckboxes = true,
CheckedObjects doesn't include child objects that were never made visible.
How do you include the child objects in the list that have not been
expanded in the tree by the user? (Once expanded, they are included.)
This works okay since there aren't many children below each root and they're only one-level deep. Maybe it's because I'm new to the control, but I couldn't figure out any other way. I'm open to suggestions on a different approach. Thanks.
Unfortunately the kludge fails for objects that were never made visible in the control by the user and whose ancestor was unchecked. I have the ParentGetter working fine. It returns the correct parent object for the child. What am I missing? This is all very confusing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's the fix I came up with. Area is the parent that each Fruit has a reference to. Note that the kludge above must run before this.
IEnumerable<Fruit> sel = tvl.CheckedObjectsEnumerable.OfType<Fruit>();
IEnumerable<Fruit> query = from f in sel
where (tvl.IsChecked(f.Area) || tvl.IsCheckedIndeterminate(f.Area))
select f;
foreach (Fruit fruit in query)
...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Totally cheesy but simple solution is to call ExpandAll() right before calling CheckedObjects. In my case I'm using TreeListView in a dialog box and only need to enumerate CheckedObjects after the dialog closes so the expand is hidden from view.
I definitely need to circle back and implement something more elegant later but this will work for now.
Tom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to get a list of the checked items. Does anyone have a code snippet, etc.
This does not work: ListView.CheckedListViewItemCollection item = dataTreeListView.CheckedItems; Any clue would really be appreciated.
All the sample code I see allows you to check a row object. How does one get the entire list of checked objects? Surely someone knows how? Even a little hint may help.
It's very easy:
When using a TreeListView with HierarchicalCheckboxes = true, CheckedObjects doesn't include child objects that were never made visible. How do you include the child objects in the list that have not been expanded in the tree by the user? (Once expanded, they are included.)
You can't.
You will have to write that logic yourself.
Phillip Piper phillip.piper@gmail.com
A man's life does not consist in the abundance of his possessions
On 16 September 2016 at 05:25, Brian Buttolph bbuttolph@users.sf.net
wrote:
This works okay since there aren't many children below each root and they're only one-level deep. Maybe it's because I'm new to the control, but I couldn't figure out any other way. I'm open to suggestions on a different approach. Thanks.
Unfortunately the kludge fails for objects that were never made visible in the control by the user and whose ancestor was unchecked. I have the ParentGetter working fine. It returns the correct parent object for the child. What am I missing? This is all very confusing.
Here's the fix I came up with. Area is the parent that each Fruit has a reference to. Note that the kludge above must run before this.
Totally cheesy but simple solution is to call ExpandAll() right before calling CheckedObjects. In my case I'm using TreeListView in a dialog box and only need to enumerate CheckedObjects after the dialog closes so the expand is hidden from view.
I definitely need to circle back and implement something more elegant later but this will work for now.
Tom