Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making an explorer like app in C# windows form. It lists all files and folders creates XML file from selected path and fills tree view with that info. Every folder has details(Folder Name, Folder Size and Number of Files) and every files has details(File name, File size (bytes), File creation, File last access time, File last modified time).

By now I have managed to display details in tree view and when tree node is selected it displays those details, what I want is that in tree view shows only tree node names and when selected it shows details in list view.

What I have tried:

This is where i create tree node:

private void AddTreeNode(XElement xElement, TreeNode treeNode)
        {
            foreach (var att in xElement.Attributes())
            {
                treeNode.Text = treeNode.Text + " " + att.Name.LocalName + ":" + att.Value;
            }

            foreach (XElement childElement in xElement.Elements())
            {
                TreeNode Node = treeNode.Nodes[treeNode.Nodes.Add(new TreeNode(childElement.Value))];
                AddTreeNode(childElement, Node);
            }
        }



And this is where I tried to display it in list view:

private void folderBrowserTree_AfterSelect(object sender, TreeViewEventArgs e)
        {            
            listDetails.Items.Clear();
            string str = folderBrowserTree.SelectedNode.Text;

            var details = str.Split();
            listDetails.Items.Add("Name: " + details[0]);
            
            for (int i = 1; i < details.Length; i++)
            {
                listDetails.Items.Add(details[i]);
            }

        }
Posted
Updated 20-Jul-17 21:13pm
Comments
PIEBALDconsult 20-Jul-17 21:44pm    
And?
How about popping up a window with the ListBox? Or a DataGridView? That's what I do.
Member 13320673 21-Jul-17 6:24am    
How to do that? I switched list view with list box but the problem stays, I have to write all details in tree view in order to show them in list box. I want just tree node name in tree and details of selected node in list box

1 solution

You should split your form into two halves, see SplitContainer Class[^]
 
Share this answer
 
Comments
Member 13320673 21-Jul-17 6:18am    
And how is that going to help me?
Richard MacCutchan 21-Jul-17 6:22am    
I don't know; perhaps you should make your question clearer.

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