EditorPartCollection コンストラクター

定義

EditorPartCollection クラスの新しいインスタンスを初期化します。

オーバーロード

EditorPartCollection()

EditorPartCollection クラスの新しい空のインスタンスを初期化します。

EditorPartCollection(ICollection)

EditorPartCollection コントロールの ICollection コレクションを渡すことによって、EditorPart クラスの新しいインスタンスを初期化します。

EditorPartCollection(EditorPartCollection, ICollection)

EditorPartCollection コントロールの EditorPartCollection コレクション、および追加の EditorPart コントロールの ICollection コレクションを渡すことによって、EditorPart クラスの新しいインスタンスを初期化します。

EditorPartCollection()

EditorPartCollection クラスの新しい空のインスタンスを初期化します。

public:
 EditorPartCollection();
public EditorPartCollection ();
Public Sub New ()

注釈

コンストラクターは EditorPartCollection 、 クラスの空のインスタンスを EditorPartCollection 初期化します。 コンストラクターのこのオーバーロードは、 メソッドの CreateEditorParts クラスによって内部的に使用されEditorZone、空のコレクション オブジェクトを作成します。 次に、ゾーンは、子ゾーン テンプレートで宣言されているすべての EditorPart コントロールのインスタンスを作成し、内部メソッドを使用してコレクションに追加します。

コンストラクターのこのオーバーロードを使用して、 EditorPartCollection の新しいインスタンス EditorPartCollection を作成し、それにコントロールを追加 EditorPart することはできません。 代わりに、コンストラクターに対して他のオーバーロードのいずれかを使用する EditorPartCollection 必要があります。

こちらもご覧ください

適用対象

EditorPartCollection(ICollection)

EditorPartCollection コントロールの ICollection コレクションを渡すことによって、EditorPart クラスの新しいインスタンスを初期化します。

public:
 EditorPartCollection(System::Collections::ICollection ^ editorParts);
public EditorPartCollection (System.Collections.ICollection editorParts);
new System.Web.UI.WebControls.WebParts.EditorPartCollection : System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.EditorPartCollection
Public Sub New (editorParts As ICollection)

パラメーター

editorParts
ICollection

ICollection コントロールの EditorPart

次のコード例は、カスタム EditorPartCollection を作成する方法を示しています。コレクションが読み取り専用であっても、バッチ操作を実行してコレクション内の個々 EditorPart のコントロールを変更します。 この例を実行するために必要な完全なコードについては、クラスの概要の「例」セクションを EditorPartCollection 参照してください。

イベントの Button1_Click コードは、 オブジェクトを ArrayList 作成し、ページ内の 3 つの EditorPart コントロールのうちの 2 つを オブジェクトに追加し、 コンストラクターを使用して新しい EditorPartCollection オブジェクトを EditorPartCollection 作成します。 また、コレクションが読み取り専用であっても、基になる EditorPart コントロールを変更する方法も示します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>

ブラウザーでページを読み込み、ページを編集モードに切り替えるには、[表示モード] ドロップダウン リスト コントロールで [編集] を選択します。 コントロールのタイトル バー TextDisplayWebPart にある動詞メニュー (下向き矢印) をクリックし、[ 編集 ] をクリックしてコントロールを編集できます。 編集ユーザー インターフェイス (UI) が表示されると、すべてのコントロールを EditorPart 表示できます。 [ EditorPartCollection の作成 ] ボタンをクリックすると、オブジェクトに追加された 2 つの EditorPart コントロールに対する効果が EditorPartCollection 表示されます。

注釈

コンストラクターは EditorPartCollection 、 クラスのインスタンスを EditorPartCollection 初期化し、コントロールの EditorPart コレクションを渡します。 これは、新しいEditorPartCollectionオブジェクトをEditorPartCollection作成し、それにコントロールを追加EditorPartするために使用できるコンストラクターの 1 つのオーバーロードです。

コンストラクターによって作成されたインスタンスは読み取り専用ですが EditorPartCollection 、コレクション内の個々 EditorPart のコントロールにプログラムでアクセスし、そのプロパティとメソッドを呼び出すことができます。

コンストラクターを EditorPartCollection 使用する一般的なシナリオの 1 つは、関連するグループの内容、外観、位置の変更など、一連の EditorPart コントロール全体に対してバッチ操作を実行する場合です。

コンストラクターを EditorPartCollection 使用するもう 1 つの一般的なシナリオは、ユーザーがコントロールのカスタム EditorPart プロパティを編集できるように、サーバー コントロールに関連付けるカスタム コントロールを開発することです。 このシナリオでは、サーバー コントロールは インターフェイスを実装する IWebEditable 必要があり、そのタスクの一部として メソッドを CreateEditorParts 実装する必要があります。 このメソッドでは、カスタム EditorPart コントロールがサーバー コントロールを編集できるようにするには、 オブジェクトなどのインスタンスにコントロールを追加EditorPartするICollectionArrayList必要があります。 その後、コントロールの EditorPart コレクションをコンストラクターに EditorPartCollection 渡して新しい EditorPartCollection オブジェクトを作成できます。このオブジェクトは EditorZoneBase 、ゾーンがすべてのコントロールを設定し、編集プロセスを開始するために使用します。

こちらもご覧ください

適用対象

EditorPartCollection(EditorPartCollection, ICollection)

EditorPartCollection コントロールの EditorPartCollection コレクション、および追加の EditorPart コントロールの ICollection コレクションを渡すことによって、EditorPart クラスの新しいインスタンスを初期化します。

public:
 EditorPartCollection(System::Web::UI::WebControls::WebParts::EditorPartCollection ^ existingEditorParts, System::Collections::ICollection ^ editorParts);
public EditorPartCollection (System.Web.UI.WebControls.WebParts.EditorPartCollection existingEditorParts, System.Collections.ICollection editorParts);
new System.Web.UI.WebControls.WebParts.EditorPartCollection : System.Web.UI.WebControls.WebParts.EditorPartCollection * System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.EditorPartCollection
Public Sub New (existingEditorParts As EditorPartCollection, editorParts As ICollection)

パラメーター

existingEditorParts
EditorPartCollection

ゾーン内の既存の ICollection コントロールの EditorPart

editorParts
ICollection

ゾーン内にはないがプログラムで作成された、ICollection コントロールの EditorPart

こちらもご覧ください

適用対象