日期:2014-05-18  浏览次数:20794 次

◆TreeView对节点添加修改删除操作◆
求一TreeView,对节点进行 添加,修改,删除,移动操作的详细代码。谢谢!

------解决方案--------------------
C# code

      //右键选取
      private void treeMailView_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                TreeNode tn = treeMailView.GetNodeAt(e.X, e.Y);
                if (tn != null)
                {
                    treeMailView.SelectedNode = tn;
                }
            }
            if (e.Button == MouseButtons.Left)
            {
                TreeNode tn = treeMailView.GetNodeAt(e.X, e.Y);
                if (tn != null)
                {
                    Tn = tn;
                }
            }
        }
//拖拽
        private Point Position = new sb.To

------解决方案--------------------
帮顶!+关注
------解决方案--------------------
http://www.componentart.com/webui/demos/demos_control-specific/treeview/programming_client/add_removeDisable/WebForm1.aspx
------解决方案--------------------
HTML code
Default.aspx.cs文件:
using System.Xml;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("data.xml"));
        XmlNode node = doc.DocumentElement;
        InitTree ( this.TreeView1.Nodes, node );
    }

    private void InitTree ( TreeNodeCollection nodes, XmlNode node )
    {
        XmlNodeList nodeList = node.ChildNodes;
        foreach ( XmlNode subNode in nodeList )
        {
            TreeNode tmpNode = new TreeNode ();
            tmpNode.Text = ((XmlElement)subNode).GetAttribute("name");
            tmpNode.NavigateUrl = ((XmlElement)subNode).GetAttribute("url");
            nodes.Add ( tmpNode );
            InitTree ( tmpNode.ChildNodes, subNode );
        }
    }
}

data.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<root>
  <baidu name="Baidu" url="http://www.baidu.com">
    <hao name="Hao" url="http://www.hao123.com">
      <wangyi name="Wangyi" url="http://www.163.com">
      </wangyi>
    </hao>
    <sina name="Sina" url="http://www.sina.com.cn">
      <qq name="QQ" url="http://www.qq.com">
      </qq>
    </sina>
  </baidu>
</root>

------解决方案--------------------
我得BLOG例有源码