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

Dim instance As EditorPartCollection Dim editorPart As EditorPart Dim returnValue As Boolean returnValue = instance.Contains(editorPart)
戻り値
EditorPart がコレクション内にあるかどうかを示すブール値。


特定の EditorPart コントロールが EditorPartCollection オブジェクト内にあるかどうかを判断する方法を次のコード例に示します。例の実行に必要なコード全体については、EditorPartCollection クラスの概要で「例」を参照してください。
Button1_Click イベントのコードでは、LayoutEditorPart1 コントロールは、それ以外のコントロールを追加する場合には EditorPartCollection オブジェクトに追加されません。LayoutEditorPart1 コントロールがコレクション内にないことを確認するために、コードでは Contains メソッドが使用されます。
<script runat="server"> Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) Dim list As New ArrayList(2) list.Add(AppearanceEditorPart1) list.Add(PropertyGridEditorPart1) ' Pass an ICollection object to the constructor. Dim myParts As New EditorPartCollection(list) Dim editor As EditorPart For Each editor In myParts editor.BackColor = System.Drawing.Color.LightBlue editor.Description = "My " + editor.DisplayTitle + " editor." Next editor ' Use the IndexOf property to locate an EditorPart control. Dim propertyGridPart As Integer = _ myParts.IndexOf(PropertyGridEditorPart1) myParts(propertyGridPart).ChromeType = PartChromeType.TitleOnly ' Use the Contains method to see if an EditorPart exists. If Not myParts.Contains(LayoutEditorPart1) Then LayoutEditorPart1.BackColor = System.Drawing.Color.LightYellow End If ' Use the CopyTo method to create an array of EditorParts. Dim partArray(2) As EditorPart partArray(0) = LayoutEditorPart1 myParts.CopyTo(partArray, 1) Label1.Text = "<h3>EditorParts in Custom Array</h3>" Dim ePart As EditorPart For Each ePart In partArray Label1.Text += ePart.Title + "<br />" Next ePart End Sub </script>
<script runat="server"> protected void Button1_Click(object sender, EventArgs e) { ArrayList list = new ArrayList(2); list.Add(AppearanceEditorPart1); list.Add(PropertyGridEditorPart1); // Pass an ICollection object to the constructor. EditorPartCollection myParts = new EditorPartCollection(list); foreach (EditorPart editor in myParts) { editor.BackColor = System.Drawing.Color.LightBlue; editor.Description = "My " + editor.DisplayTitle + " editor."; } // Use the IndexOf property to locate an EditorPart control. int propertyGridPart = myParts.IndexOf(PropertyGridEditorPart1); myParts[propertyGridPart].ChromeType = PartChromeType.TitleOnly; // Use the Contains method to see if an EditorPart exists. if(!myParts.Contains(LayoutEditorPart1)) LayoutEditorPart1.BackColor = System.Drawing.Color.LightYellow; // Use the CopyTo method to create an array of EditorParts. EditorPart[] partArray = new EditorPart[3]; partArray[0] = LayoutEditorPart1; myParts.CopyTo(partArray,1); Label1.Text = "<h3>EditorParts in Custom Array</h3>"; foreach (EditorPart ePart in partArray) { Label1.Text += ePart.Title + "<br />"; } } </script>
ブラウザでページを読み込む場合、[Display Mode] ドロップダウン リスト コントロールの [編集] を選択することにより、ページを編集モードに切り替えることができます。TextDisplayWebPart コントロールのタイトル バーで動詞メニュー (下向きの矢印) をクリックし、[編集] をクリックすることにより、コントロールを編集できます。編集中のユーザー インターフェイス (UI) が表示状態の場合、すべての EditorPart コントロールを表示できます。[Create EditorPartCollection] ボタンをクリックすると、LayoutEditorPart1 コントロールの背景色が他のコントロールとは異なっていることを確認できます。これは、このコントロールが EditorPartCollection オブジェクトの一部ではないからです。

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


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

- EditorPartCollection.Contains メソッドのページへのリンク