EditorPartCollection コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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 クラスの空のインスタンスを初期化します。 コンストラクターのこのオーバーロードは、空のコレクション オブジェクトを作成するために、EditorZone メソッドのCreateEditorParts クラスによって内部的に使用されます。 その後、ゾーンは、子ゾーン テンプレートで宣言されているすべての 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 の作成] ボタンをクリックすると、EditorPart オブジェクトに追加された 2 つのEditorPartCollection コントロールに対する効果が表示されます。
注釈
EditorPartCollection コンストラクターは、EditorPartCollection クラスのインスタンスを初期化し、EditorPart コントロールのコレクションを渡します。 これは、新しいEditorPartCollection オブジェクトを作成し、EditorPartCollection コントロールを追加するために使用できるEditorPart コンストラクターのオーバーロードの 1 つです。
コンストラクターによって作成された EditorPartCollection インスタンスは読み取り専用ですが、プログラムを使用してコレクション内の個々の EditorPart コントロールにアクセスし、そのプロパティとメソッドを呼び出すことができます。
EditorPartCollection コンストラクターを使用する一般的なシナリオの 1 つは、関連するグループの内容、外観、位置の変更など、一連のEditorPart コントロール全体に対してバッチ操作を実行する場合です。
EditorPartCollection コンストラクターを使用するもう 1 つの一般的なシナリオは、ユーザーがコントロールのカスタム プロパティを編集できるように、サーバー コントロールに関連付けるカスタム EditorPart コントロールを開発することです。 このシナリオでは、サーバー コントロールは IWebEditable インターフェイスを実装する必要があり、そのタスクの一部として、 CreateEditorParts メソッドを実装する必要があります。 このメソッドでは、カスタム EditorPart コントロールでサーバー コントロールを編集できるようにするには、EditorPart オブジェクトなどのICollection インスタンスにArrayList コントロールを追加する必要があります。 その後、 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。