TreeNodeBindingCollection.Remove メソッド
アセンブリ: System.Web (system.web.dll 内)


Remove メソッドを使用して、指定した TreeNodeBinding オブジェクトをコレクションから削除します。そのノードの後に続く項目はすべて、空いた位置を埋め合わせるように上に移動します。移動した項目のインデックスも更新されます。
または、RemoveAt メソッドを使用して、特定のインデックス位置にあるノードを削除することもできます。Clear メソッドを使用して、コレクション内のすべてのノードを削除することもできます。

Remove メソッドを使用して、TreeNodeBindingCollection オブジェクトから TreeNodeBinding オブジェクトをプログラムによって削除するコード例を次に示します。この例を正しく実行するには、このセクションの末尾にある XML データを Book.xml ファイルにコピーする必要があります。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Use the Remove method to remove the TreeNodeBinding object ' for the third-level nodes (index 2). Dim oldBinding As TreeNodeBinding = BookTreeView.DataBindings(2) BookTreeView.DataBindings.Remove(oldBinding) ' Create a new TreeNodeBinding object and set its properties. Dim newBinding As TreeNodeBinding = New TreeNodeBinding newBinding.DataMember = "Section" newBinding.TextField = "Subject" ' Use the Add method to add the TreeNodeBinding object to the ' DataBindings collection. BookTreeView.DataBindings.Add(newBinding) End Sub </script> <html> <body> <form runat="server"> <h3>TreeNodeBindingCollection Add and Remove 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#" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Use the Remove method to remove the TreeNodeBinding object // for the third-level nodes (index 2). TreeNodeBinding oldBinding = BookTreeView.DataBindings[2]; BookTreeView.DataBindings.Remove(oldBinding); // Create a new TreeNodeBinding object and set its properties. TreeNodeBinding newBinding = new TreeNodeBinding(); newBinding.DataMember = "Section"; newBinding.TextField = "Subject"; // Use the Add method to add the TreeNodeBinding object to the // DataBindings collection. BookTreeView.DataBindings.Add(newBinding); } </script> <html> <body> <form runat="server"> <h3>TreeNodeBindingCollection Add and Remove 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からTreeNodeBindingCollection.Remove メソッドを検索する場合は、下記のリンクをクリックしてください。

- TreeNodeBindingCollection.Remove メソッドのページへのリンク