本文整理匯總了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.
}
}