I try to populate list of file revision to treeview. I have a list of revision file like a below.
1.17
1.17.1.1
1.17.1.2
1.17.1.2.1.1
1.17.1.2.1.2
1.17.1.2.1.2.1.1
1.17.1.2.1.2.1.2
1.17.1.2.1.2.1.3
1.17.1.2.1.2.1.3.1.1
1.17.1.2.1.2.1.3.1.2
1.17.1.2.1.2.1.3.2.1
1.17.1.2.1.2.1.4
1.17.1.2.1.2.1.5
1.17.1.2.1.2.1.5.1.1
1.17.1.2.1.2.1.5.1.2
1.17.1.2.1.2.1.5.1.2.1.1
1.17.1.2.1.3
1.17.1.2.1.4
1.18
1.19
Now, I would like to populate it like a
1.17
1.17.1.1
1.17.1.2
1.17.1.2.1.1
1.17.1.2.1.2
1.17.1.2.1.2.1.1
1.17.1.2.1.2.1.2
1.17.1.2.1.2.1.3
1.17.1.2.1.2.1.3.1.1
1.17.1.2.1.2.1.3.1.2
1.17.1.2.1.2.1.3.2.1
1.17.1.2.1.2.1.4
1.17.1.2.1.2.1.5
1.17.1.2.1.2.1.5.1.1
1.17.1.2.1.2.1.5.1.2
1.17.1.2.1.2.1.5.1.2.1.1
1.17.1.2.1.3
1.17.1.2.1.4
1.18
1.19
My idea is classified it by level
1.17 -> level 1
1.17.1.1 -> level 2
1.17.1.2 -> level 2
1.17.1.2.1.1 -> level 3
...
Then I use switch case to populate it to treeview
if level = 1 then parent node
else if level = 2 then child node
else if level = 3 then grandchild node
...
However, I don't know is it a right way to achieve my purpose. Is there any better way to do that?
Any help are appreciate and thanks so much
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…