0

親ノードと子ノードを含むツリー ビューがあります。ノードをクリックすると、そのノードに関する説明がテキスト ボックスに表示されます。これはすべてのノードで発生するはずです。どうすればいいですか。

私が試した私のコードは次のとおりです。

private void fetchtreeview()
    {
        TVContent.Nodes.Clear();
        DataTable topics = dsSOW.Tables["Tableofcontents$"];
        drText = dsSOW.Tables["Tableofcontents" + "$"].Select("Mappingcode is NULL");
        if (drText.Length > 0)
        {
            foreach (DataRow drItem in drText)
            {
                string ss = drItem.ItemArray[1].ToString();

                string ss1 = drItem.ItemArray[0].ToString();
                if (ss1 != string.Empty)
                {
                    TreeNode node = new TreeNode(ss, ss1);
                    //txtArea.Text = node.Text;
                    node.PopulateOnDemand = false;
                    TVContent.Nodes.Add(node);

                    PopulateNode(node);
                }
            }
        }
    }
    protected void PopulateNode(TreeNode node1)
    {
        decimal order = Convert.ToDecimal(node1.Value);
        drText = dsSOW.Tables["Tableofcontents" + "$"].Select("Mappingcode='" + order + "'");
         if (drText.Length > 0)
        {
            foreach (DataRow drItem in drText)
             {
                string ss = drItem.ItemArray[1].ToString();
                string ss1 = drItem.ItemArray[0].ToString();
                //decimal order1 = Convert.ToDecimal(ss1.ToString());
                TreeNode node = new TreeNode(ss, ss1);    
                DataRow[] drText1 = dsSOW.Tables["Content" + "$"].Select("contentcode='" + ss1 + "'");               
                if (drText1.Length > 0)
                {
                   foreach (DataRow drItem1 in drText1)
                    {
                        txtArea.Text = txtArea.Text + drItem1.ItemArray[1].ToString();
                    }
                }      
                node1.ChildNodes.Add(node);
                snode = node.Value;
                if (snode != string.Empty)
                {
                    drText = dsSOW.Tables["Tableofcontents$"].Select("Mappingcode='" + snode + "'");
                    if (drText.Length > 0)
                    {
                        PopulateNode(node);
                    }
                }
            }
          }    
        TVContent.Attributes.Add("OnClick", "OnTreeClick(event)");
        //TVContent.Attributes.Add("onmouseover", "showToolTip(event)");
         } 

このコードを実装すると、ページ読み込み自体のノードに関する説明が得られます。ノードをクリックした後にのみ表示されるようにします。そして、データセットから説明の値を取得します。

助けてください。

4

1 に答える 1

0

イベント private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) があります。

このイベントでは、e.Node を取得します。

「e.Node.getsomething」から、選択したノードに関する情報を取得できます。

于 2012-10-15T09:07:59.627 に答える