Click here to Skip to main content
15,066,319 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Gurus and Masters!

I'm looking for a solution for the following issue I have:

Imagine an application like a File manager, where I have a list of files with details. (name - language - Guid - user etc...)

I can easily sort/modify these items, but in some rare cases these files could have slices (sub elements) /basically the same file as the parent just sliced to ranges/
Something like this:

First file | LangCode | Guid | User
Second file | LangCode | Guid | User
Third file
Third file 1-2 | LangCode | Guid | User
Third file 3-4 | LangCode | Guid | User
Third file 5-6 | LangCode | Guid | User
Forth file | LangCode | Guid | User

And the issue is with the slices. When I reorder, filter the listview these slices are not under the parent document anymore.

All these listviewitems are added programmatically.

If something is not clear, just let me know and i will gladly provide further info.

Thanks! :)

What I have tried:

The only "solution" what i was able to achieve is simply not filtering the files...but as this would be an extra feature, i would like to fix this somehow.

Right now, my last idea was to iterate through the items and if it has subitems, somehow insert them after the parent document. But of course I haven't found a solution for this as well..
Updated 18-May-20 3:45am

1 solution

You have to add a property that adds a parent/child relationship between the items. The property would be something like

public string ParentGuid { get; set; }

and only children would have this property populated. Side benefit - you can even have multiple layers of children in the hierarchy.

This would allow you to write custom sorting code in your collection that would handle it for you. What that custom sorting could would look like I cannot tell you.
Member 13050667 19-May-20 13:19pm
Thank you, but I already defined these as enums like {File, SliceParent, Slice} but i still don't know how to add and keep the slices under the parent. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900