using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace treeview
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
treeView1.Nodes.Add("根节点"); //创建根目录
for (int i = 0; i <10; i++)
{
treeView1.Nodes[0].Nodes.Add("一级目录" + i.ToString());//创建一级目录
}
for (int i = 0; i < treeView1.Nodes[0].Nodes.Count; i++)//创建一级目录节点数
{
for (int j = 0; j < 5; j++)
{
treeView1.Nodes[0].Nodes.Nodes.Add("二级目录" + j.ToString());//创建二级目录
}//以上为个人手工敲击代码,
}
}
}
}
}
}
}
}
|