Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to have an array of treenode in such a way that if i add a custom node along with that the remaining Nodes declared in the array should be added as child nodes to that custom node added.


UPDATE:

Answer added by OP himself.
Posted
Updated 31-Aug-10 8:22am
v2

Sounds like you need to write the code to suit your need, I don't believe it exists otherwise.
 
Share this answer
 
Comments
demouser743 31-Aug-10 3:03am    
But i am unable to find how make Nodes as an array of treenode
Christian Graus 31-Aug-10 3:06am    
I am not sure if you can create them outside of a tree control, but you can put them in a tree and create an array of references to them.
Got the answer:
C#
private void AddNew_Click(object sender, EventArgs e)
        {
            Stream myStream;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.InitialDirectory = @"C:\";
            //saveFileDialog1.CheckFileExists = true;
            //saveFileDialog1.CheckPathExists = true;
            saveFileDialog1.DefaultExt = "txt";
            saveFileDialog1.Filter = "(*.txt)|*.txt";
            saveFileDialog1.FilterIndex = 2;
            saveFileDialog1.RestoreDirectory = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                   
                    string FileName = saveFileDialog1.FileName;
                    TreeNode newNode = new TreeNode(FileName);
                    newNode.SelectedImageIndex = 1;
                    tvwACH.SelectedNode.Nodes.Add(newNode);
                    newNode.Nodes.Add("FileHeader");
                    newNode.Nodes.Add("BatchHeader");
                    newNode.Nodes.Add("EntryDetail");
                    // TODO: Add code here to save the current contents of the form to a file.
                    //myStream.Close();                
                }
            }
        }
 
Share this answer
 
v4

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