日期:2014-05-17 浏览次数:20865 次
public partial class FormMenuConfig : Form
{
public FormMenuConfig()
{
InitializeComponent();
Init();
}
private void Init()
{
ImageList imageList = new ImageList();
imageList.Images.Add(Image.FromFile("Images/folder.gif"));
imageList.Images.Add(Image.FromFile("Images/page.gif"));
treeMenu.ImageList = imageList;
TreeNode nodeRoot = new TreeNode();
nodeRoot.ImageIndex = 0;
nodeRoot.Text = "根节点";
TreeNode nodeDir1 = new TreeNode();
nodeDir1.ImageIndex = 0;
nodeDir1.Text = "目录1";
nodeRoot.Nodes.Add(nodeDir1);
TreeNode nodePage1 = new TreeNode();
nodePage1.ImageIndex = 1;
nodePage1.Text = "页面1";
nodeRoot.Nodes.Add(nodePage1);
//treeMenu是TreeView
treeMenu.Nodes.Add(nodeRoot);
}
}
private void treeView2_AfterSelect(object sender, TreeViewEventArgs e)
&nbs