开发者

How do I loop through specific subitems of a ListView?

I'm making a program that uses a ListView to view the directories and files in the selected directory. The ListView itself has two columns and is set to Details view. The two columns are Folder Name (the directory selected from a button) and Movie Names (which will list all movies in the selected directory on the ListView).

What I would like the ListView to do is after the folder has been added to the ListView the subitems should be hidden until the left-hand column (selected directory) is clicked.

I have attempted to loop through the subitems of a ListView, but the problem is that not only does it pri开发者_如何学Pythonnt out all the files and folders within the directory, it also loops through and prints out the directory name as well.

For those that would like to see the code and project I have provided a Download link below.

http://www8.zippyshare.com/v/75161785/file.html

Also here is part of my code to display the array of files and folders within a directory, as you can see my problem is that it also loops through my item which i would like it to display only once.

        for (int i = 0; i < jointArray.Length; i++)
        {
                ListViewItem item = new ListViewItem(fi.Name);
                item.SubItems.Add(jointArray[i]);
                listView1.Items.Add(item);
        }


Looks like you need a TreeControl with each directory collapsed until you click it (much like windows explorer).

Then you can recursively look through all your folders & files and add them to the treeview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜