本文整理汇总了C#中System.Web.UI.Design.TemplateGroupCollection类的典型用法代码示例。如果您正苦于以下问题:C# TemplateGroupCollection类的具体用法?C# TemplateGroupCollection怎么用?C# TemplateGroupCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemplateGroupCollection类属于System.Web.UI.Design命名空间,在下文中一共展示了TemplateGroupCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: if
//引入命名空间
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.
}
}