TemplateGroupCollection Class
TOC
Collapse the table of content
Expand the table of content

TemplateGroupCollection Class

 

Represents a collection of TemplateGroup objects within a control designer. This class cannot be inherited.

Namespace:   System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)

System.Object
  System.Web.UI.Design.TemplateGroupCollection

public sealed class TemplateGroupCollection : IList, ICollection, 
	IEnumerable

NameDescription
System_CAPS_pubmethodTemplateGroupCollection()

Initializes a new instance of the TemplateGroupCollection class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of TemplateGroup objects in the collection.

System_CAPS_pubpropertyItem[Int32]

Gets or sets a TemplateGroup object at the specified index in the collection.

NameDescription
System_CAPS_pubmethodAdd(TemplateGroup)

Adds the specified TemplateGroup object to the end of the collection.

System_CAPS_pubmethodAddRange(TemplateGroupCollection)

Adds the template groups in an existing TemplateGroupCollection object to the current TemplateGroupCollection object.

System_CAPS_pubmethodClear()

Removes all groups from the collection.

System_CAPS_pubmethodContains(TemplateGroup)

Determines whether the specified group is contained within the collection.

System_CAPS_pubmethodCopyTo(TemplateGroup[], Int32)

Copies the groups in the collection to a compatible one-dimensional array, starting at the specified index of the target array.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(TemplateGroup)

Returns the index of the specified TemplateGroup object within the collection.

System_CAPS_pubmethodInsert(Int32, TemplateGroup)

Inserts a TemplateGroup object into the collection at the specified index.

System_CAPS_pubmethodRemove(TemplateGroup)

Removes the specified TemplateGroup object from the collection.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the TemplateGroup object at the specified index within the collection.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see CopyTo.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see GetEnumerator.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Add(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Add.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Clear()

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Clear.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Contains(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Contains.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.IndexOf(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IndexOf.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Insert(Int32, Object)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Insert.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Remove(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Remove.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.RemoveAt(Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see RemoveAt.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.Count

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see Count.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IsSynchronized.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see SyncRoot.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsFixedSize

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IsFixedSize.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsReadOnly

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IsReadOnly.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.Item[Int32]

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see the IList class.

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

The ControlDesigner class, and any derived class, defines the TemplateGroups property as a TemplateGroupCollection object. The TemplateGroupCollection property is typically used only by a design host such as Visual Studio 2005.

The collection dynamically increases in size as objects are added. Indexes in this collection are zero-based. Use the Count property to determine how many groups are in the collection.

Additionally, use the TemplateGroupCollection methods and properties to provide the following functionality:

  • The Add method to add a single group to the collection.

  • The Insert method to add a group at a particular index within the collection.

  • The Remove method to remove a group.

  • The RemoveAt method to remove the group at a particular index.

  • The Contains method to determine whether a particular group is already in the collection.

  • The IndexOf method to retrieve the index of a group within the collection.

  • The Item indexer to get or set the group at a particular index, using array notation.

  • The AddRange method to add multiple groups to the collection.

    You can add multiple groups either as an array of groups or as a TemplateGroupCollection object that you retrieve through the TemplateGroups property of another control designer.

  • The Clear method to remove all groups from the collection.

The following code example demonstrates how to define a simple control designer that is derived from the ControlDesigner class. The derived control designer implements the TemplateGroups property by getting the template groups that are defined for the base class and adding a template group that is specific to the derived control designer.

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.
    }

}

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft