日期:2014-05-17  浏览次数:21204 次

新手求教TreeView控件问题
我是新手照着书去打代码的,有几个地方不明白,还有一个错误 又不会改 请高手帮忙


        private void Form1_Load(object sender, EventArgs e)
        {
            this.InitTreeView(this.treeView1);
            this.AddNode(this.treeView1);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.treeView1.ExpandAll();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.treeView1.CollapseAll();
        }


        public class Book
        {
            public string BookName = string.Empty;
            public string Author = string.Empty;
            public string Price = string.Empty;
        }

        private void InitTreeView(TreeView treeView)
        {
            treeView.CheckBoxes = false;
            treeView.FullRowSelect = true;
            ImageList imagelist = new ImageList();
            imagelist.Images.Add(new Icon ("0.ico"));
            imagelist.Images.Add(new Icon  ("1.ico"));
            imagelist.Images.Add(new Icon  ("2.ico"));
            treeView.ImageList = imagelist;
            treeView.LabelEdit = false;
            treeView.PathSeparator = "\\";