内测机试 居委会

    xiaoxiao2021-03-25  49

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using System.Xml; namespace 读书日记系统 { public partial class Form1 : Form { House h=new House(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { XmlDocument xml = new XmlDocument(); xml.Load("Address.xml"); XmlNode root = xml.DocumentElement; h.jiedao = root.Attributes["name"].Value; TreeNode rootNode = new TreeNode(); rootNode.Text = h.jiedao; treeView1.Nodes.Add(rootNode); foreach (XmlNode item in root.ChildNodes) { TreeNode oneNode = new TreeNode(); oneNode.Text = item.Attributes["name"].Value; foreach (XmlNode child in item.ChildNodes) { TreeNode twoNode = new TreeNode(); twoNode.Text = child.Attributes["name"].Value; foreach (XmlNode node in child.ChildNodes) { TreeNode threeNode = new TreeNode(); threeNode.Text = node.InnerText; twoNode.Nodes.Add(threeNode); } oneNode.Nodes.Add(twoNode); } rootNode.Nodes.Add(oneNode); } } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { textBox1.Text = "石牌街道"; TreeNode node = this.treeView1.SelectedNode; if (node.Level == 1) { textBox2.Text = node.Text; } else if (node.Level == 2) { textBox3.Text = node.Text; textBox2.Text = node.Parent.Text; } else if (node.Level == 3) { textBox4.Text = node.Text; textBox3.Text = node.Parent.Text; textBox2.Text = node.Parent.Parent.Text; } } } } namespace 读书日记系统 { public class House { public House() { } public string Juwei { get; set; }//居委会 private string fang1; public string Fang1 { get { return fang1; } set { fang1 = value; } } private string xiaoqu; public string XiaoQu { get { return xiaoqu; } set { xiaoqu = value; } } public string jiedao; public string JieDao { get { return jiedao; } set { jiedao = value; } } } }
    转载请注明原文地址: https://ju.6miu.com/read-39019.html

    最新回复(0)