VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之XML与TreeView

  1。treeview代码书写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
private void Form1_Load(object sender, EventArgs e)
{<br data-filtered="filtered">                   //代码为TreeView添加子项
    treeView1.ContextMenuStrip = contextMenuStrip1;
    TreeNode tn = new TreeNode("默认");
   
    treeView1.Nodes.Add(tn);
 
}
 
private void button1_Click(object sender, EventArgs e)
{<br data-filtered="filtered">                  //代码为TreeView添加子项
    string text = textBox1.Text;
    TreeNode tn = new TreeNode(text);
    TreeNode tr = treeView1.SelectedNode;
    tr.Nodes.Add(tn);
 
}
 
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{<br data-filtered="filtered">                      //删除选中项
    treeView1.SelectedNode.Remove();
}

 2.XML基本用法

     1XML文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="utf-8" ?>
<Computers>
  
 
<Computer typr="222">
 
  <Name>LenovoY460</Name>
 
  <Price>5000</Price>
  <CPU>酷睿i3</CPU>
  
  
</Computer>
 
 
  <Computer typr="2223">
 
    <Name>Dell</Name>
 
    <Price>7000</Price>
    <CPU>酷睿i7</CPU>
 
 
  </Computer>
  
  
</Computers>