TemplateGroupCollection Klasa

Definicja

Reprezentuje kolekcję TemplateGroup obiektów w projektancie kontrolek. Klasa ta nie może być dziedziczona.

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
Dziedziczenie
TemplateGroupCollection
Implementuje

Przykłady

W poniższym przykładzie kodu pokazano, jak zdefiniować prostego projektanta kontrolek pochodzącego ControlDesigner z klasy . Pochodny projektant kontrolek implementuje TemplateGroups właściwość, uzyskując grupy szablonów zdefiniowane dla klasy bazowej i dodając grupę szablonów specyficzną dla pochodnego projektanta kontrolek.

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

Uwagi

Klasa i dowolna ControlDesigner klasa pochodna TemplateGroups definiują właściwość jako TemplateGroupCollection obiekt. Właściwość TemplateGroupCollection jest zwykle używana tylko przez hosta projektu, takiego jak Visual Studio 2005.

Kolekcja dynamicznie zwiększa rozmiar w miarę dodawania obiektów. Indeksy w tej kolekcji są oparte na zera. Count Użyj właściwości , aby określić, ile grup znajduje się w kolekcji.

Ponadto użyj TemplateGroupCollection metod i właściwości, aby zapewnić następujące funkcje:

  • Metoda dodawania Add pojedynczej grupy do kolekcji.

  • Metoda dodawania Insert grupy w określonym indeksie w kolekcji.

  • Metoda Remove usuwania grupy.

  • Metoda RemoveAt usuwania grupy w określonym indeksie.

  • Metoda określania Contains , czy określona grupa znajduje się już w kolekcji.

  • Metoda IndexOf pobierania indeksu grupy w kolekcji.

  • Indeksator Item[] do pobierania lub ustawiania grupy w określonym indeksie przy użyciu notacji tablicowej.

  • Metoda dodawania AddRange wielu grup do kolekcji.

    Można dodać wiele grup jako tablicę grup lub jako TemplateGroupCollection obiekt pobierany za pośrednictwem TemplateGroups właściwości innego projektanta kontrolek.

  • Metoda Clear usuwania wszystkich grup z kolekcji.

Konstruktory

TemplateGroupCollection()

Inicjuje nowe wystąpienie klasy TemplateGroupCollection.

Właściwości

Count

Pobiera liczbę TemplateGroup obiektów w kolekcji.

Item[Int32]

Pobiera lub ustawia TemplateGroup obiekt w określonym indeksie w kolekcji.

Metody

Add(TemplateGroup)

Dodaje określony TemplateGroup obiekt na końcu kolekcji.

AddRange(TemplateGroupCollection)

Dodaje grupy szablonów w istniejącym TemplateGroupCollection obiekcie do bieżącego TemplateGroupCollection obiektu.

Clear()

Usuwa wszystkie grupy z kolekcji.

Contains(TemplateGroup)

Określa, czy określona grupa jest zawarta w kolekcji.

CopyTo(TemplateGroup[], Int32)

Kopiuje grupy w kolekcji do zgodnej tablicy jednowymiarowej, począwszy od określonego indeksu tablicy docelowej.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IndexOf(TemplateGroup)

Zwraca indeks określonego TemplateGroup obiektu w kolekcji.

Insert(Int32, TemplateGroup)

Wstawia TemplateGroup obiekt do kolekcji w określonym indeksie.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
Remove(TemplateGroup)

Usuwa określony TemplateGroup obiekt z kolekcji.

RemoveAt(Int32)

Usuwa obiekt w TemplateGroup określonym indeksie w kolekcji.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

ICollection.CopyTo(Array, Int32)

Aby uzyskać opis tego członka, zobacz CopyTo(Array, Int32).

ICollection.Count

Aby uzyskać opis tego członka, zobacz Count.

ICollection.IsSynchronized

Aby uzyskać opis tego członka, zobacz IsSynchronized.

ICollection.SyncRoot

Aby uzyskać opis tego członka, zobacz SyncRoot.

IEnumerable.GetEnumerator()

Aby uzyskać opis tego członka, zobacz GetEnumerator().

IList.Add(Object)

Aby uzyskać opis tego członka, zobacz Add(Object).

IList.Clear()

Aby uzyskać opis tego członka, zobacz Clear().

IList.Contains(Object)

Aby uzyskać opis tego członka, zobacz Contains(Object).

IList.IndexOf(Object)

Aby uzyskać opis tego elementu członkowskiego, zobacz IndexOf(Object).

IList.Insert(Int32, Object)

Aby uzyskać opis tego elementu członkowskiego, zobacz Insert(Int32, Object).

IList.IsFixedSize

Aby uzyskać opis tego elementu członkowskiego, zobacz IsFixedSize.

IList.IsReadOnly

Aby uzyskać opis tego elementu członkowskiego, zobacz IsReadOnly.

IList.Item[Int32]

Aby uzyskać opis tego elementu członkowskiego, zobacz klasę IList .

IList.Remove(Object)

Aby uzyskać opis tego elementu członkowskiego, zobacz Remove(Object).

IList.RemoveAt(Int32)

Aby uzyskać opis tego elementu członkowskiego, zobacz RemoveAt(Int32).

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy elementu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable elementu na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy

Zobacz też