• 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);
     }
    }
    //}}
    ------------------------------------------------------------------------------------------

  • 相关阅读:
    hadoop mysql install (5)
    hadoop redis install (4)
    hadoop mongodb install(3)
    hadoop hbase install (2)
    水平交错效果显示图像
    实现推拉效果显示图片
    百叶窗效果显示图像
    以椭圆形显示图像
    图像的放大与缩小
    鼠标拖拽图像
  • 原文地址:https://www.cnblogs.com/Amor/p/223272.html
Copyright © 2020-2023  润新知