TreeNodeBindingCollectionとは? わかりやすく解説

TreeNodeBindingCollection クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

TreeView コントロール内の TreeNodeBinding オブジェクトコレクション表します。このクラス継承できません。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 TreeNodeBindingCollection
    Inherits StateManagedCollection
Dim instance As TreeNodeBindingCollection
public sealed class TreeNodeBindingCollection
 : StateManagedCollection
public ref class TreeNodeBindingCollection
 sealed : public StateManagedCollection
public final class TreeNodeBindingCollection
 extends StateManagedCollection
public final class TreeNodeBindingCollection
 extends StateManagedCollection
解説解説

TreeNodeBindingCollection クラスは、TreeView コントロール存在する TreeNodeBinding オブジェクトコレクション格納および管理する場合使用されます。TreeView コントロールは、その DataBindings プロパティTreeNodeBindingCollection クラス使用します

DataBindings プロパティには、データ項目とそのバインド先のノードとの間の関係を定義する TreeNodeBinding オブジェクト含まれています。複数属性を持つ XML 要素どのように、各データ項目に複数プロパティ含まれているデータ ソースバインドする場合ノードにはデータ項目の ToString メソッドから返される値が既定表示されます。XML 要素場合ノードには要素名が表示されます。これはメニュー ツリーの基になる構造体を示す以外はあまり用途はありません。ツリー ノードバインディング指定することにより、ノード特定のデータ項目のプロパティバインドできますDataBindings コレクションプログラムにより設定できますが、通常宣言によって設定されます。

ツリー ノード バインディング宣言して設定するには、次のように操作します。

  1. TreeView コントロール開始タグ終了タグの間で <DataBindings>開始タグ終了タグ入れ子にします。

  2. 指定するツリー ノード バインディングごとに、<DataBindings>開始タグ終了タグの間に <asp:TreeNodeBinding> 要素入れます

TreeNodeBinding オブジェクト追加および削除することにより、TreeNodeBindingCollection オブジェクトプログラムによって管理できますTreeNodeBinding オブジェクトコレクション追加するには、Add メソッドまたは Insert メソッド使用しますコレクションからノード削除するには、Remove、RemoveAt、または StateManagedCollection.Clear の各メソッド使用します

TreeNodeBindingCollection クラスは、コレクション内の項目にアクセスするための複数方法サポートしてます。

使用例使用例

このセクションには、2 つコード例含まれています。最初コード例では、宣言によって TreeNodeBindingCollection オブジェクトに値を代入する方法示します2 番目のコード例では、プログラムによって TreeNodeBindingCollection オブジェクトに値を代入する方法示します

宣言によって TreeNodeBindingCollection オブジェクトに値を代入するコード例次に示します。この例を正しく実行するには、このセクション末尾にある XML データを Book.xml ファイルコピーする必要があります

<%@ Page Language="VB" %>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView XML Data Binding Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID=BookXmlDataSource
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book"
 TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter"
 TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section"
 TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>

      <asp:XmlDataSource id="BookXmlDataSource"
  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

<%@ Page Language="C#" %>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView XML Data Binding Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID=BookXmlDataSource
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>

      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

プログラムによって TreeNodeBindingCollection オブジェクトに値を代入するコード例次に示します。この例を正しく実行するには、このセクション末尾にあるサンプル XML データを Book.xml ファイルコピーする必要があります

<%@ Page Language="VB" %>

<script runat="server">

  Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)

    ' Create a new TreeView control.
    Dim NewTree As New TreeView

    ' Set the properties of the TreeView control.
    NewTree.ID = "BookTreeView"
    NewTree.DataSourceID = "BookXmlDataSource"

    ' Create the tree node binding relationship.

    ' Create the root node binding.
    Dim RootBinding As New
 TreeNodeBinding
    RootBinding.DataMember = "Book"
    RootBinding.TextField = "Title"

    ' Create the parent node binding.
    Dim ParentBinding As New
 TreeNodeBinding
    ParentBinding.DataMember = "Chapter"
    ParentBinding.TextField = "Heading"

    ' Create the leaf node binding.
    Dim LeafBinding As New
 TreeNodeBinding
    LeafBinding.DataMember = "Section"
    LeafBinding.TextField = "Heading"

    ' Add bindings to the DataBindings collection.
    NewTree.DataBindings.Add(RootBinding)
    NewTree.DataBindings.Add(ParentBinding)
    NewTree.DataBindings.Add(LeafBinding)

    ' Manually register the event handler for the SelectedNodeChanged
 event.
    AddHandler NewTree.SelectedNodeChanged, AddressOf
 Node_Change

    ' Add the TreeView control to the Controls collection of the PlaceHolder
 control.
    ControlPlaceHolder.Controls.Add(NewTree)

  End Sub

  Sub Node_Change(ByVal sender As
 Object, ByVal e As EventArgs)

    ' Retrieve the TreeView control from the Controls collection of
 the PlaceHolder control.
    Dim LocalTree As TreeView = CType(ControlPlaceHolder.FindControl("BookTreeView"),
 TreeView)

    ' Display the selected node.
    Message.Text = "You selected: " & LocalTree.SelectedNode.Text

  End Sub

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView Constructor Example</h3>
      
      <asp:PlaceHolder id="ControlPlaceHolder"
 runat="server">
      </asp:PlaceHolder>
   
      <asp:XmlDataSource id="BookXmlDataSource"
  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
      
      <br><br>
      
      <asp:Label id="Message" runat="server"/>
    
    </form>
  </body>
</html>

<%@ Page Language="C#" %>

<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {

    // Create a new TreeView control.
    TreeView NewTree = new TreeView();

    // Set the properties of the TreeView control.
    NewTree.ID = "BookTreeView";
    NewTree.DataSourceID = "BookXmlDataSource";

    // Create the tree node binding relationship.

    // Create the root node binding.
    TreeNodeBinding RootBinding = new TreeNodeBinding();
    RootBinding.DataMember = "Book";
    RootBinding.TextField = "Title";

    // Create the parent node binding.
    TreeNodeBinding ParentBinding = new TreeNodeBinding();
    ParentBinding.DataMember = "Chapter";
    ParentBinding.TextField = "Heading";

    // Create the leaf node binding.
    TreeNodeBinding LeafBinding = new TreeNodeBinding();
    LeafBinding.DataMember = "Section";
    LeafBinding.TextField = "Heading";

    // Add bindings to the DataBindings collection.
    NewTree.DataBindings.Add(RootBinding);
    NewTree.DataBindings.Add(ParentBinding); 
    NewTree.DataBindings.Add(LeafBinding);

    // Manually register the event handler for the SelectedNodeChanged
 event.
    NewTree.SelectedNodeChanged += new EventHandler(this.Node_Change);

    // Add the TreeView control to the Controls collection of the PlaceHolder
 control.
    ControlPlaceHolder.Controls.Add(NewTree);

  }

  void Node_Change(Object sender, EventArgs e)
  {

    // Retrieve the TreeView control from the Controls collection of
 the PlaceHolder control.
    TreeView LocalTree = (TreeView)ControlPlaceHolder.FindControl("BookTreeView");

    // Display the selected node.
    Message.Text = "You selected: " + LocalTree.SelectedNode.Text;

  }

</script>

<html>
  <body>
    <form runat="server">
    
      <h3>TreeView Constructor Example</h3>
      
      <asp:PlaceHolder id="ControlPlaceHolder" runat="server">
      </asp:PlaceHolder>
   
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
      
      <br><br>
      
      <asp:Label id="Message" runat="server"/>
    
    </form>
  </body>
</html>

前のコード例使用する XML データ次に示します

<Book Title="Book Title">
    <Chapter Heading="Chapter 1">
       <Section Heading="Section 1">
       </Section>
       <Section Heading="Section 2">
       </Section>
    </Chapter>
    <Chapter Heading="Chapter 2">
        <Section Heading="Section 1">
        </Section>
    </Chapter>
</Book>
継承階層継承階層
System.Object
   System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.TreeNodeBindingCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeNodeBindingCollection メンバ
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
TreeNodeBinding クラス
DataBindings
Add
Insert
Remove
RemoveAt
StateManagedCollection.Clear

TreeNodeBindingCollection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Count  StateManagedCollection コレクション格納されている要素の数を取得します。 ( StateManagedCollection から継承されます。)
パブリック プロパティ Item TreeNodeBindingCollection オブジェクト内の指定したインデックス位置にある TreeNodeBinding オブジェクト取得または設定します
参照参照

関連項目

TreeNodeBindingCollection クラス
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
TreeNodeBinding クラス
DataBindings
Add
Insert
Remove
RemoveAt
StateManagedCollection.Clear

TreeNodeBindingCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定した TreeNodeBinding オブジェクトを TreeNodeBindingCollection オブジェクト末尾追加します
パブリック メソッド Clear  StateManagedCollection コレクションからすべての項目を削除します。 ( StateManagedCollection から継承されます。)
パブリック メソッド Contains 指定した TreeNodeBinding オブジェクトコレクション内にあるかどうか確認します
パブリック メソッド CopyTo オーバーロードされますTreeNodeBindingCollection オブジェクトからすべての項目をコピーします
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator  StateManagedCollection コレクション反復処理する反復子返します。 ( StateManagedCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IndexOf コレクション内の指定した TreeNodeBinding オブジェクトインデックス確認します
パブリック メソッド Insert 指定した TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクト指定したインデックス位置挿入します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定した TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクトから削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクトから削除します
パブリック メソッド SetDirty  強制的に StateManagedCollection コレクション全体ビューステートシリアル化ます。 ( StateManagedCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TreeNodeBindingCollection クラス
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
TreeNodeBinding クラス
DataBindings
Add
Insert
Remove
RemoveAt
StateManagedCollection.Clear

TreeNodeBindingCollection メンバ

TreeView コントロール内の TreeNodeBinding オブジェクトコレクション表します。このクラス継承できません。

TreeNodeBindingCollection データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count  StateManagedCollection コレクション格納されている要素の数を取得します。(StateManagedCollection から継承されます。)
パブリック プロパティ Item TreeNodeBindingCollection オブジェクト内の指定したインデックス位置にある TreeNodeBinding オブジェクト取得または設定します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定した TreeNodeBinding オブジェクトを TreeNodeBindingCollection オブジェクト末尾追加します
パブリック メソッド Clear  StateManagedCollection コレクションからすべての項目を削除します。 (StateManagedCollection から継承されます。)
パブリック メソッド Contains 指定した TreeNodeBinding オブジェクトコレクション内にあるかどうか確認します
パブリック メソッド CopyTo オーバーロードされますTreeNodeBindingCollection オブジェクトからすべての項目をコピーします
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator  StateManagedCollection コレクション反復処理する反復子返します。 (StateManagedCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IndexOf コレクション内の指定した TreeNodeBinding オブジェクトインデックス確認します
パブリック メソッド Insert 指定した TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクト指定したインデックス位置挿入します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定した TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクトから削除します
パブリック メソッド RemoveAt 指定したインデックス位置にある TreeNodeBinding オブジェクトTreeNodeBindingCollection オブジェクトから削除します
パブリック メソッド SetDirty  強制的に StateManagedCollection コレクション全体ビューステートシリアル化ます。 (StateManagedCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TreeNodeBindingCollection クラス
System.Web.UI.WebControls 名前空間
TreeView
TreeNode クラス
TreeNodeBinding クラス
DataBindings
Add
Insert
Remove
RemoveAt
StateManagedCollection.Clear


このページでは「.NET Framework クラス ライブラリ リファレンス」からTreeNodeBindingCollectionを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTreeNodeBindingCollectionを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTreeNodeBindingCollection を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TreeNodeBindingCollection」の関連用語

TreeNodeBindingCollectionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TreeNodeBindingCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS