[已解决]如何有一个Treenode数组 [英] [Solved] How to have an array of Treenode

查看:51
本文介绍了[已解决]如何有一个Treenode数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一个treenode数组,如果我添加一个自定义节点,并且在数组中声明的其余Node应该作为子节点添加到该自定义节点中.


更新:

OP自己添加的答案.

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.

推荐答案

听起来像您需要编写代码来满足自己的需要,我不相信它会以其他方式存在.
Sounds like you need to write the code to suit your need, I don''t believe it exists otherwise.


得到答案:
Got the answer:
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();                
                }
            }
        }


这篇关于[已解决]如何有一个Treenode数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆