导航

C# TreeView AfterSelect事件 从节点中获取所需数据

Posted on 2009-05-22 12:44  kingwangzhen  阅读(2475)  评论(0编辑  收藏  举报

/// <summary>
        /// 从Treeview客户节点中获取信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SalesOrdertreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //Level 为2的节点为客户节点层次
            if(SalesOrdertreeView.SelectedNode.Level==2&&SalesOrdertreeView.SelectedNode!=null)
            {
                label2.Text = SalesOrdertreeView.SelectedNode.Tag.ToString();
                label4.Text = SalesOrdertreeView.SelectedNode.Text;
                label5.Text = SalesOrdertreeView.SelectedNode.FullPath;
            }else
            {
                label2.Text = "";
                label4.Text = "";
                label5.Text = "";
               
            }

        }