コード例 #1
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show("请选择一个节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DialogResult result = MessageBox.Show("确定要删除此节点的所有内容吗?", "删除节点", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (result)
                {
                case DialogResult.Yes:
                    TreeXML tx = new TreeXML();
                    tx.DeleXml(starpath + @"\List.xml", treeView1.SelectedNode.Text);
                    treeView1.SelectedNode.Remove();
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
        }
コード例 #2
0
        private void toolStripButton2_Click(object sender, EventArgs e)   //删除分组
        {
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show("请选择一个节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //添加一个人性化的判断,使得删除操作显得不那么草率
                DialogResult dResult = MessageBox.Show("确定要删除此节点的所有内容吗?", "删除节点", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (dResult)
                {
                case DialogResult.Yes:
                    TreeXML TreXml = new TreeXML();
                    TreXml.DeleXml(starpath + @"\List.xml", treeView1.SelectedNode.Text); //节点都是在List.xml中删除
                    treeView1.SelectedNode.Remove();                                      //删除节点
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
        }
コード例 #3
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) //显示AddressList中的信息到dataGridView中
        {
            TreeXML TreeXml = new TreeXML();                                   //实例化一个对象

            //调用TreeXml中的GetPersonInfo方法,根据treeView中的分组将相关信息显示到dataGridView1中
            dataGridView1.DataSource = TreeXml.GetPersonInfo(starpath + @"\AddressList.xml", treeView1.SelectedNode.Text);    //调用方法
        }
コード例 #4
0
        private void 添加下级分组ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();        //弹出添加下级分组窗体
            if (form2.groupName != "") //如果信息输入完整
            {
                TreeNode tn = new TreeNode();
                tn.Text = form2.groupName;
                TreeNode tn1 = treeView1.SelectedNode; //找到根节点
                tn1.Nodes.Add(tn);                     //添加子节点tn
                try
                {
                    if (treeView1.SelectedNode.Text == "")
                    {
                        MessageBox.Show("没有选择父组名!");
                    }
                    TreeXML TreXML = new TreeXML();
                    TreXML.AddXmlNextNode(starpath + @"\List.xml", form2.groupName, treeView1.SelectedNode.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "登陆时间" + DateTime.Now.ToString();
            toolStripButton4_Click(null, null);
            treeView1.Nodes.Clear();
            TreeXML TreeXml = new TreeXML();

            TreeXml.XMLToTree(starpath + @"\List.xml", treeView1);
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)                //加载窗体
        {
            toolStripStatusLabel1.Text = "登录时间" + DateTime.Now.ToString(); //显示时间
            toolStripButton4_Click(null, null);                            //读取所有联系人信息,即一共有多少条联系人记录
            //读取组并显示在treeView1上
            treeView1.Nodes.Clear();                                       //这里是删除我们在安装控件时输入的一些树节点吧?
            TreeXML TreeXml = new TreeXML();                               //实例化对象

            TreeXml.XMLToTree(starpath + @"\List.xml", treeView1);         //调用方法
        }
コード例 #7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();
            if (form2.groupName != "")
            {
                TreeNode tn = new TreeNode();
                tn.Text = form2.groupName;
                treeView1.Nodes.Add(tn);
                if (treeView1.SelectedNode.Parent == null)
                {
                    TreeXML tx = new TreeXML();
                    tx.AddXmlNode(starpath + @"\List.xml", form2.groupName);
                }
            }
        }
コード例 #8
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();                                                 //弹出添加修改分组窗体
            if (form2.groupName != "")
            {
                TreeNode tn = new TreeNode();
                tn.Text = form2.groupName;
                treeView1.Nodes.Add(tn);
                /*写入XML文件*/
                if (treeView1.SelectedNode.Parent == null)              //判断是否是父节点
                {
                    TreeXML TreXml = new TreeXML();
                    TreXml.AddXmlNode(starpath + @"\List.xml", form2.groupName);
                }
            }
        }
コード例 #9
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();
            if (form2.groupName != "")
            {
                if (treeView1.SelectedNode == null)
                {
                    MessageBox.Show("请选择一个节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    TreeXML tx = new TreeXML();
                    tx.AlterXml(starpath + @"\List.xml", treeView1.SelectedNode.Text, form2.groupName);
                    treeView1.SelectedNode.Text = form2.groupName;
                }
            }
        }
コード例 #10
0
        private void toolStripButton1_Click(object sender, EventArgs e)    //添加同级分组
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();               //弹出添加修改分组窗体
            if (form2.groupName != "")        //如果输入的组名不为空
            {
                TreeNode tn = new TreeNode(); //新建一个树节点
                tn.Text = form2.groupName;    //为该树节点赋值
                treeView1.Nodes.Add(tn);      //将新创建的树节点添加到树节点集合的末尾

                /*写入XML文件*/
                if (treeView1.SelectedNode.Parent == null)    //判断是否是父节点
                {
                    TreeXML TreXML = new TreeXML();
                    TreXML.AddXmlNode(starpath + @"\List.xml", form2.groupName);     //starpath为文件路径,form2.groupName为所添加分组的组名
                }
            }
        }
コード例 #11
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeXML TreeXml = new TreeXML();

            dataGridView1.DataSource = TreeXml.GetPersonInfo(starpath + @"\AddressList.xml", treeView1.SelectedNode.Text);
        }