Language

CatalogPartCollection.Item[] プロパティ

定義

位置または一意の識別子に従って、コレクションの特定のメンバーを返します。

オーバーロード

名前 説明
Item[Int32]

コレクション内の位置に基づいて、コレクションのメンバーを取得または設定します。

Item[String]

一意の文字列識別子に基づいてコレクションのメンバーを返します。

Item[Int32]

コレクション内の位置に基づいて、コレクションのメンバーを取得または設定します。

public:
 property System::Web::UI::WebControls::WebParts::CatalogPart ^ default[int] { System::Web::UI::WebControls::WebParts::CatalogPart ^ get(int index); };
public System.Web.UI.WebControls.WebParts.CatalogPart this[int index] { get; }
member this.Item(int) : System.Web.UI.WebControls.WebParts.CatalogPart
Default Public ReadOnly Property Item(index As Integer) As CatalogPart

パラメーター

index
Int32

コレクション内の特定の CatalogPart のインデックス。

プロパティ値

コレクション内の指定したインデックス位置にある CatalogPart 。

例

次のコード例は、インデックスを使用して CatalogPartCollection オブジェクトのメンバーにアクセスする方法を示しています。 この例を実行するために必要な完全なコードについては、「 CatalogPartCollection クラスの概要」トピックの「例」セクションを参照してください。

Button1_Click メソッドのコードは、CatalogPartCollectionという名前の新しいmyParts オブジェクトを作成します。 このメソッドでは、 Item[] インデクサーを使用してコレクションの最初のメンバーから情報を取得します。

protected void Button1_Click(object sender, EventArgs e)
{
  ArrayList list = new ArrayList(2);
  list.Add(PageCatalogPart1);
  list.Add(DeclarativeCatalogPart1);
  // Pass an ICollection object to the constructor.
  CatalogPartCollection myParts = new CatalogPartCollection(list);
  foreach (CatalogPart catalog in myParts)
  {
    catalog.Description = "My " + catalog.DisplayTitle;
  }

  // Use the IndexOf property to locate a CatalogPart control.
  int PageCatalogPartIndex = myParts.IndexOf(PageCatalogPart1);
  myParts[PageCatalogPartIndex].ChromeType = PartChromeType.TitleOnly;

  // Use the Contains method to see if a CatalogPart control exists.
  if (myParts.Contains(PageCatalogPart1))
  {
    WebPart closedWebPart = null;
    WebPartDescriptionCollection descriptions = PageCatalogPart1.GetAvailableWebPartDescriptions();
    if (descriptions.Count > 0)
    {
      closedWebPart = PageCatalogPart1.GetWebPart(descriptions[0]);
      closedWebPart.AllowClose = false;
    }
  }
  
  // Use indexers to display the details of the CatalogPart controls.
  Label1.Text = String.Empty;
  Label1.Text =
    "<h3>PageCatalogPart Details</h3>" +
    "ID: " + myParts[0].ID + "<br />" +
    "Count: " + myParts[0].GetAvailableWebPartDescriptions().Count;
  Label1.Text += 
    "<h3>DeclarativeCatalogPart Details</h3>" +
    "ID: " + myParts["DeclarativeCatalogPart1"].ID + "<br />" +
    "Count: " + myParts["DeclarativeCatalogPart1"].GetAvailableWebPartDescriptions().Count;
}
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) 
    Dim list As New ArrayList(2)
    list.Add(PageCatalogPart1)
    list.Add(DeclarativeCatalogPart1)
    ' Pass an ICollection object to the constructor.
    Dim myParts As New CatalogPartCollection(list)
    Dim catalog As CatalogPart
    For Each catalog In  myParts
        catalog.Description = "My " + catalog.DisplayTitle
    Next catalog
    
    ' Use the IndexOf property to locate a CatalogPart control.
    Dim PageCatalogPartIndex As Integer = _
      myParts.IndexOf(PageCatalogPart1)
    myParts(PageCatalogPartIndex).ChromeType = PartChromeType.TitleOnly
    
    ' Use the Contains method to see if a CatalogPart control exists.
    If myParts.Contains(PageCatalogPart1) Then
        Dim closedWebPart As WebPart = Nothing
        Dim descriptions As WebPartDescriptionCollection = _
          PageCatalogPart1.GetAvailableWebPartDescriptions()
        If descriptions.Count > 0 Then
            closedWebPart = PageCatalogPart1.GetWebPart(descriptions(0))
            closedWebPart.AllowClose = False
        End If
    End If
    
    ' Use indexers to display the details of the CatalogPart controls.
    Label1.Text = String.Empty
    Label1.Text = _
      "<h3>PageCatalogPart Details</h3>" & _
      "ID: " & myParts(0).ID + "<br />" & _
      "Count: " & myParts(0).GetAvailableWebPartDescriptions().Count
    Label1.Text += _
      "<h3>DeclarativeCatalogPart Details</h3>" & _
      "ID: " & myParts("DeclarativeCatalogPart1").ID & "<br />" & _
      "Count: " & myParts("DeclarativeCatalogPart1") _
        .GetAvailableWebPartDescriptions().Count

End Sub 

ブラウザーでページを読み込むときに、[表示モード] ドロップダウン リスト コントロールで [カタログ] を選択して、ページを カタログモード に切り替えることができます。 [ CatalogPart プロパティの表示 ] ボタンをクリックすると、 CatalogPartCollection オブジェクトにアクセスし、含まれている CatalogPart コントロールの特定のプロパティが表示されます。 PageCatalogPart コントロール内で使用可能なサーバー コントロールの数は、Item[] メソッドで Button1_Click インデクサーを使用して取得されます。

注釈

Item[] インデクサーを使用すると、インデックスを使用してCatalogPart オブジェクト内の基になるCatalogPartCollection コントロールにアクセスし、そのプロパティ値または呼び出しメソッドを変更できます。

こちらもご覧ください

適用対象

Item[String]

一意の文字列識別子に基づいてコレクションのメンバーを返します。

public:
 property System::Web::UI::WebControls::WebParts::CatalogPart ^ default[System::String ^] { System::Web::UI::WebControls::WebParts::CatalogPart ^ get(System::String ^ id); };
public System.Web.UI.WebControls.WebParts.CatalogPart this[string id] { get; }
member this.Item(string) : System.Web.UI.WebControls.WebParts.CatalogPart
Default Public ReadOnly Property Item(id As String) As CatalogPart

パラメーター

id
String

コレクション内の特定の CatalogPart の一意識別子。

プロパティ値

ID が CatalogPart の値と等しいコレクション内の最初のid。

例

次のコード例では、文字列 ID 値を使用して、 CatalogPartCollection オブジェクトのメンバーにアクセスする方法を示します。 この例を実行するために必要な完全なコードについては、「 CatalogPartCollection クラスの概要」トピックの「例」セクションを参照してください。

Button1_Click メソッドのコードは、CatalogPartCollectionという名前の新しいmyParts オブジェクトを作成します。 このメソッドは、 Item[] インデクサーを使用して、コレクションの 2 番目のメンバーである DeclarativeCatalogPart コントロールに関する情報を取得します。

protected void Button1_Click(object sender, EventArgs e)
{
  ArrayList list = new ArrayList(2);
  list.Add(PageCatalogPart1);
  list.Add(DeclarativeCatalogPart1);
  // Pass an ICollection object to the constructor.
  CatalogPartCollection myParts = new CatalogPartCollection(list);
  foreach (CatalogPart catalog in myParts)
  {
    catalog.Description = "My " + catalog.DisplayTitle;
  }

  // Use the IndexOf property to locate a CatalogPart control.
  int PageCatalogPartIndex = myParts.IndexOf(PageCatalogPart1);
  myParts[PageCatalogPartIndex].ChromeType = PartChromeType.TitleOnly;

  // Use the Contains method to see if a CatalogPart control exists.
  if (myParts.Contains(PageCatalogPart1))
  {
    WebPart closedWebPart = null;
    WebPartDescriptionCollection descriptions = PageCatalogPart1.GetAvailableWebPartDescriptions();
    if (descriptions.Count > 0)
    {
      closedWebPart = PageCatalogPart1.GetWebPart(descriptions[0]);
      closedWebPart.AllowClose = false;
    }
  }
  
  // Use indexers to display the details of the CatalogPart controls.
  Label1.Text = String.Empty;
  Label1.Text =
    "<h3>PageCatalogPart Details</h3>" +
    "ID: " + myParts[0].ID + "<br />" +
    "Count: " + myParts[0].GetAvailableWebPartDescriptions().Count;
  Label1.Text += 
    "<h3>DeclarativeCatalogPart Details</h3>" +
    "ID: " + myParts["DeclarativeCatalogPart1"].ID + "<br />" +
    "Count: " + myParts["DeclarativeCatalogPart1"].GetAvailableWebPartDescriptions().Count;
}
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) 
    Dim list As New ArrayList(2)
    list.Add(PageCatalogPart1)
    list.Add(DeclarativeCatalogPart1)
    ' Pass an ICollection object to the constructor.
    Dim myParts As New CatalogPartCollection(list)
    Dim catalog As CatalogPart
    For Each catalog In  myParts
        catalog.Description = "My " + catalog.DisplayTitle
    Next catalog
    
    ' Use the IndexOf property to locate a CatalogPart control.
    Dim PageCatalogPartIndex As Integer = _
      myParts.IndexOf(PageCatalogPart1)
    myParts(PageCatalogPartIndex).ChromeType = PartChromeType.TitleOnly
    
    ' Use the Contains method to see if a CatalogPart control exists.
    If myParts.Contains(PageCatalogPart1) Then
        Dim closedWebPart As WebPart = Nothing
        Dim descriptions As WebPartDescriptionCollection = _
          PageCatalogPart1.GetAvailableWebPartDescriptions()
        If descriptions.Count > 0 Then
            closedWebPart = PageCatalogPart1.GetWebPart(descriptions(0))
            closedWebPart.AllowClose = False
        End If
    End If
    
    ' Use indexers to display the details of the CatalogPart controls.
    Label1.Text = String.Empty
    Label1.Text = _
      "<h3>PageCatalogPart Details</h3>" & _
      "ID: " & myParts(0).ID + "<br />" & _
      "Count: " & myParts(0).GetAvailableWebPartDescriptions().Count
    Label1.Text += _
      "<h3>DeclarativeCatalogPart Details</h3>" & _
      "ID: " & myParts("DeclarativeCatalogPart1").ID & "<br />" & _
      "Count: " & myParts("DeclarativeCatalogPart1") _
        .GetAvailableWebPartDescriptions().Count

End Sub 

ブラウザーでページを読み込むときに、[表示モード] ドロップダウン リスト コントロールで [カタログ] を選択して、ページを カタログモード に切り替えることができます。 [ CatalogPart プロパティの表示 ] ボタンをクリックすると、 CatalogPartCollection オブジェクトにアクセスし、含まれている CatalogPart コントロールの特定のプロパティが表示されます。 DeclarativeCatalogPart コントロール内で使用可能なサーバー コントロールの数は、Item[] メソッドで Button1_Click インデクサーを使用して取得されます。

注釈

Item[] インデクサーを使用すると、文字列識別子を使用して、CatalogPart オブジェクト内の基になるCatalogPartCollection コントロールにアクセスできます。 CatalogPartCollection オブジェクトは読み取り専用ですが、インデクサーによってアクセスされる基になるコントロールのプロパティ値を変更したり、メソッドを呼び出したりできます。

こちらもご覧ください

適用対象