TemplateGroupCollection クラス

定義

コントロール デザイナー内の TemplateGroup オブジェクトのコレクションを表します。 このクラスは継承できません。

public ref class TemplateGroupCollection sealed : System::Collections::IList
public sealed class TemplateGroupCollection : System.Collections.IList
type TemplateGroupCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public NotInheritable Class TemplateGroupCollection
Implements IList
継承
TemplateGroupCollection
実装

次のコード例は、クラスから派生した単純なコントロール デザイナーを定義する方法を ControlDesigner 示しています。 派生コントロール デザイナーは、基本クラスに対して定義されているテンプレート グループを取得し、派生コントロール デザイナーに固有のテンプレート グループを追加することで、プロパティを実装 TemplateGroups します。

using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace Examples.AspNet
{
    // Define a simple control designer that adds a
    // template group to the template group collection.
    class DerivedControlDesigner : System.Web.UI.Design.ControlDesigner
    {
        private DerivedControl internalControl = null;

        private const String templateGroupName = "My template group";
        private const String templateDefinitionName1 = "First";
        private const String templateDefinitionName2 = "Second";
        private TemplateGroup internalGroup = null;

        // Override the read-only TemplateGroups property.
        // Get the base group collection, and add a group 
        // with two template definitions for the derived
        // control designer.
        public override TemplateGroupCollection TemplateGroups
        {
            get
            {
                // Start with the groups defined by the base designer class.
                TemplateGroupCollection groups = base.TemplateGroups;

                if (internalGroup == null) 
                {
                    // Define a new group with two template definitions.
                    internalGroup = new TemplateGroup(templateGroupName, 
                                                internalControl.ControlStyle);

                    TemplateDefinition templateDef1 = new TemplateDefinition(this, 
                        templateDefinitionName1, internalControl, 
                        templateDefinitionName1, internalControl.ControlStyle);

                    TemplateDefinition templateDef2 = new TemplateDefinition(this, 
                        templateDefinitionName2, internalControl, 
                        templateDefinitionName2, internalControl.ControlStyle);

                    internalGroup.AddTemplateDefinition(templateDef1);
                    internalGroup.AddTemplateDefinition(templateDef2);
                }

                // Add the new template group to the collection.
                groups.Add(internalGroup);

                return groups;
            }
        }
    }

    // Define a simple web control, and associate it with the designer.
    [DesignerAttribute(typeof(DerivedControlDesigner),
                       typeof(IDesigner))]
    public class DerivedControl : WebControl
    {
        // Define derived control behavior here.
    }
}
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.ComponentModel
Imports System.ComponentModel.Design

Namespace Examples.AspNet

    ' Define a simple control designer that adds a
    ' template group to the template group collection.
    Class DerivedControlDesigner
        Inherits System.Web.UI.Design.ControlDesigner

        Private Dim internalControl As DerivedControl = Nothing
    
        Private Const templateGroupName As String = "My template group"
        Private Const templateDefinitionName1 As String = "First"
        Private Const templateDefinitionName2 As String = "Second"
        Private Dim internalGroup As TemplateGroup = Nothing

        ' Override the read-only TemplateGroups property.
        ' Get the base group collection, and add a group 
        ' with two template definitions for the derived
        ' control designer.
        Public Overrides ReadOnly Property TemplateGroups As TemplateGroupCollection
            Get

                ' Start with the groups defined by the base designer class.
                Dim groups As TemplateGroupCollection  = MyBase.TemplateGroups

                If internalGroup Is Nothing

                    ' Define a new group with two template definitions.
                    internalGroup = New TemplateGroup(templateGroupName, _
                                                internalControl.ControlStyle)

                    Dim templateDef1 As TemplateDefinition = new TemplateDefinition(Me, _
                        templateDefinitionName1, internalControl, _
                        templateDefinitionName1, internalControl.ControlStyle)

                    Dim templateDef2 As TemplateDefinition = new TemplateDefinition(Me, _
                        templateDefinitionName2, internalControl, _
                        templateDefinitionName2, internalControl.ControlStyle)

                    internalGroup.AddTemplateDefinition(templateDef1)
                    internalGroup.AddTemplateDefinition(templateDef2)

                End If

                ' Add the new template group to the collection.
                groups.Add(internalGroup)

                return groups
            End Get
        End Property

    End Class

    ' Simple Web control, derived from the Web control class.
    <DesignerAttribute(GetType(DerivedControlDesigner), GetType(IDesigner))> _
    Public Class DerivedControl
        Inherits WebControl
        
        ' Define derived control behavior here.
    End Class

End Namespace

注釈

クラス ControlDesigner と派生クラスは、プロパティを TemplateGroups オブジェクトとして TemplateGroupCollection 定義します。 このプロパティはTemplateGroupCollection、通常、Visual Studio 2005 などのデザイン ホストによってのみ使用されます。

オブジェクトが追加されると、コレクションのサイズが動的に増加します。 このコレクション内のインデックスは 0 から始まります。 このプロパティを Count 使用して、コレクション内のグループの数を確認します。

さらに、メソッドとプロパティを TemplateGroupCollection 使用して、次の機能を提供します。

  • Addコレクションに 1 つのグループを追加するメソッド。

  • コレクション内の Insert 特定のインデックスにグループを追加するメソッド。

  • Removeグループを削除するメソッド。

  • 特定の RemoveAt インデックスにあるグループを削除するメソッド。

  • 特定の Contains グループが既にコレクション内にあるかどうかを判断するメソッド。

  • IndexOfコレクション内のグループのインデックスを取得するメソッド。

  • Item[]配列表記を使用して、特定のインデックスでグループを取得または設定するインデクサー。

  • AddRangeコレクションに複数のグループを追加するメソッド。

    グループの配列として、または別のコントロール デザイナーのプロパティを TemplateGroupCollection 使用して取得するオブジェクトとして、複数のグループを TemplateGroups 追加できます。

  • Clearコレクションからすべてのグループを削除するメソッド。

コンストラクター

TemplateGroupCollection()

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

プロパティ

Count

コレクション内の TemplateGroup オブジェクト数を取得します。

Item[Int32]

コレクション内の指定したインデックス位置にある TemplateGroup オブジェクトを取得または設定します。

メソッド

Add(TemplateGroup)

指定した TemplateGroup オブジェクトをコレクションの末尾に追加します。

AddRange(TemplateGroupCollection)

既存の TemplateGroupCollection オブジェクト内のテンプレート グループを現在の TemplateGroupCollection オブジェクトに追加します。

Clear()

コレクションからすべてのグループを削除します。

Contains(TemplateGroup)

指定したグループがコレクション内に存在するかどうかを確認します。

CopyTo(TemplateGroup[], Int32)

コピー先配列の指定されたインデックスを開始位置として、コレクション内のグループを互換性がある 1 次元配列にコピーします。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IndexOf(TemplateGroup)

コレクション内の指定した TemplateGroup オブジェクトのインデックスを返します。

Insert(Int32, TemplateGroup)

コレクション内の指定したインデックス位置に、TemplateGroup オブジェクトを挿入します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
Remove(TemplateGroup)

指定した TemplateGroup オブジェクトをコレクションから削除します。

RemoveAt(Int32)

コレクション内の指定したインデックスにある TemplateGroup オブジェクトを削除します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

ICollection.CopyTo(Array, Int32)

このメンバーの詳細については、「CopyTo(Array, Int32)」をご覧ください。

ICollection.Count

このメンバーの詳細については、「Count」をご覧ください。

ICollection.IsSynchronized

このメンバーの詳細については、「IsSynchronized」をご覧ください。

ICollection.SyncRoot

このメンバーの詳細については、「SyncRoot」をご覧ください。

IEnumerable.GetEnumerator()

このメンバーの詳細については、「GetEnumerator()」をご覧ください。

IList.Add(Object)

このメンバーの詳細については、「Add(Object)」をご覧ください。

IList.Clear()

このメンバーの詳細については、「Clear()」をご覧ください。

IList.Contains(Object)

このメンバーの詳細については、「Contains(Object)」をご覧ください。

IList.IndexOf(Object)

このメンバーの詳細については、「IndexOf(Object)」をご覧ください。

IList.Insert(Int32, Object)

このメンバーの詳細については、「Insert(Int32, Object)」をご覧ください。

IList.IsFixedSize

このメンバーの詳細については、「IsFixedSize」をご覧ください。

IList.IsReadOnly

このメンバーの詳細については、「IsReadOnly」をご覧ください。

IList.Item[Int32]

このメンバーの詳細については、IList クラスのトピックを参照してください。

IList.Remove(Object)

このメンバーの詳細については、「Remove(Object)」をご覧ください。

IList.RemoveAt(Int32)

このメンバーの詳細については、「RemoveAt(Int32)」をご覧ください。

拡張メソッド

Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。

適用対象

こちらもご覧ください