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

Dim instance As EditorPartCollection Dim array As EditorPart() Dim index As Integer instance.CopyTo(array, index)

CopyTo メソッドは、EditorPartCollection オブジェクトの EditorPart コントロール、またはそれらのコントロールのサブセットかスーパーセットを格納できるカスタム配列を作成する場合に便利です。

CopyTo メソッドを使用して、EditorPart コントロールのカスタム配列を作成する方法を次のコード例に示します。例の実行に必要なコード全体については、EditorPartCollection クラスの概要で「例」を参照してください。
Button1_Click イベント内のコードは、EditorPart コントロールの配列を作成し、LayoutEditorPart1 コントロールを配列に追加します。次に、CopyTo メソッドを使用して、コントロールを EditorPartCollection オブジェクトから配列にコピーします。
<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] ボタンをクリックすると、カスタム配列内のすべてのコントロールのタイトルがページの末尾付近に一覧表示されるのを確認できます。

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.CopyTo メソッドを検索する場合は、下記のリンクをクリックしてください。

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