TreeNodeCollection.Containsとは何? わかりやすく解説 Weblio辞書 (original) (raw)
TreeNodeCollection.Contains メソッド
TreeNodeCollection.Contains メソッド
指定したツリー ノードがコレクションのメンバかどうかを確認します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
指定した TreeNode が TreeNodeCollection 内にあるかどうかを確認した後で、そのコレクションを列挙するコード例を次に示します。この例は Form に TreeView が配置され、そこに、myTreeNode2 という名前の TreeNode を含む TreeNodeCollection が割り当てられていることを前提としています。
Private Sub EnumerateTreeNodes() Dim myNodeCollection As TreeNodeCollection = myTreeView.Nodes ' Check for a node in the collection. If myNodeCollection.Contains(myTreeNode2) Then myLabel.Text += "Node2 is at index: " + myNodeCollection.IndexOf(myTreeNode2) End If myLabel.Text += ControlChars.Cr + ControlChars.Cr + _ "Elements of the TreeNodeCollection:" + ControlChars.Cr
' Create an enumerator for the collection. Dim myEnumerator As IEnumerator = myNodeCollection.GetEnumerator() While myEnumerator.MoveNext() myLabel.Text += CType(myEnumerator.Current, TreeNode).Text + ControlChars.Cr End While End Sub
private void EnumerateTreeNodes() { TreeNodeCollection myNodeCollection = myTreeView.Nodes; // Check for a node in the collection. if (myNodeCollection.Contains(myTreeNode2)) { myLabel.Text += "Node2 is at index: " + myNodeCollection.IndexOf(myTreeNode2); } myLabel.Text += "\n\nElements of the TreeNodeCollection:\n";
// Create an enumerator for the collection. IEnumerator myEnumerator = myNodeCollection.GetEnumerator(); while(myEnumerator.MoveNext()) { myLabel.Text += ((TreeNode)myEnumerator.Current).Text +"\n"; } }
private void EnumerateTreeNodes() { TreeNodeCollection myNodeCollection = myTreeView.get_Nodes(); // Check for a node in the collection. if (myNodeCollection.Contains(myTreeNode2)) { myLabel.set_Text(myLabel.get_Text() + "Node2 is at index: " + myNodeCollection.IndexOf(myTreeNode2)); } myLabel.set_Text(myLabel.get_Text() + "\n\nElements of the TreeNodeCollection:\n"); // Create an enumerator for the collection. IEnumerator myEnumerator = myNodeCollection.GetEnumerator(); while (myEnumerator.MoveNext()) { myLabel.set_Text(myLabel.get_Text() + ((TreeNode)myEnumerator.get_Current()).get_Text() + "\n"); } } //EnumerateTreeNodes
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。