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 によってサポートされていないバージョンありますサポートされているバージョンについては、「システム要件」を参照してください

バージョン情報バージョン情報

参照参照