zoukankan      html  css  js  c++  java
  • xml做TreeView

    Xml_and_TreeView:

    xml.xml:
    -----------------------------------------------------------------------------------------
    <?xml version="1.0" encoding="utf-8" ?>
    <TREENODES>
     <TREENODE TEXT="node0" EXPANDED="true">
      <TREENODE TEXT="node1" />
      <TREENODE TEXT="node2" />
     </TREENODE>
     <TREENODE TEXT="node3" NavigateURL="3.aspx" />
    </TREENODES>
    -------------------------------------------------------------------------------------------

    Form:
    -------------------------------------------------------------------------------------------
    System.Xml.XmlDocument document = new System.Xml.XmlDataDocument();
    document.Load("../../xml.xml");
    populateTreeControl(document.DocumentElement, treeView1.Nodes);
    -------------------------------------------------------------------------------------------

    -------------------------------------------------------------------------------------------
    //{{
    private void populateTreeControl(System.Xml.XmlNode document,System.Windows.Forms.TreeNodeCollection nodes)
    {
     foreach (System.Xml.XmlNode node in
     document.ChildNodes)
     {
               string text = (node.Value != null ? node.Value : (node.Attributes != null && node.Attributes.Count > 0) ?node.Attributes[0].Value : node.Name);
           TreeNode new_child = new TreeNode(text);
           nodes.Add(new_child);
           populateTreeControl(node, new_child.Nodes);
     }
    }
    //}}
    ------------------------------------------------------------------------------------------

  • 相关阅读:
    poj 3070 矩阵快速乘
    将数字放大显示
    hdu 火车入队 stack
    linq to Entity 数据库除了有主键还有唯一索引,是不是不能更新
    整理:C#写ActiveX, 从代码到打包到签名到发布的示例
    Java—FileOperator
    第二章-递归与分治策略
    第四章-贪心算法
    第五章-回溯法
    Linux中C程序调试、makefile
  • 原文地址:https://www.cnblogs.com/Amor/p/223272.html
Copyright © 2011-2022 走看看