DataGridDesigner 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
扩展 DataGrid Web 服务器控件的设计时行为。
public ref class DataGridDesigner : System::Web::UI::Design::WebControls::BaseDataListDesignerpublic class DataGridDesigner : System.Web.UI.Design.WebControls.BaseDataListDesigner[System.Web.UI.Design.SupportsPreviewControl(true)]
public class DataGridDesigner : System.Web.UI.Design.WebControls.BaseDataListDesignertype DataGridDesigner = class
    inherit BaseDataListDesigner[<System.Web.UI.Design.SupportsPreviewControl(true)>]
type DataGridDesigner = class
    inherit BaseDataListDesignerPublic Class DataGridDesigner
Inherits BaseDataListDesigner- 继承
- 属性
示例
下面的代码示例演示如何扩展 DataGridDesigner 类。 当控件呈现在CellPadding设计图面上时DataGrid,代码将重写 GetDesignTimeHtml 方法来自定义 、 BorderWidth和 BorderColor 属性。
Imports System.Diagnostics
Imports System.ComponentModel
Imports System.Drawing
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls
Namespace Examples.AspNet
    ' Create a designer class for the SimpleDataList class.
    <System.Security.Permissions.SecurityPermission( _
    System.Security.Permissions.SecurityAction.Demand, _
    Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Public Class SimpleDataListDesigner
        Inherits DataListDesigner
        Private simpleList As SimpleDataList
        ' Override the GetDesignTimeHtml method to add style to the control
        ' on the design surface.
        Public Overrides Function GetDesignTimeHtml() As String
            ' Cast the control to the Component property of the designer.
            simpleList = CType(Component, SimpleDataList)
            Dim designTimeHtml As String = Nothing
            ' Create variables to hold current property values.
            Dim oldBorderWidth As Unit = simpleList.BorderWidth
            Dim oldBorderColor As Color = simpleList.BorderColor
            ' Set the properties and generate the design-time HTML.
            If (simpleList.Enabled) Then
                Try
                    simpleList.BorderWidth = Unit.Point(5)
                    simpleList.BorderColor = Color.Purple
                    designTimeHtml = MyBase.GetDesignTimeHtml()
                    ' Call the GetErrorDesignTimeHtml method if an
                    ' exception occurs.
                Catch ex As Exception
                    designTimeHtml = GetErrorDesignTimeHtml(ex)
                    ' Return the properties to their original settings.
                Finally
                    simpleList.BorderWidth = oldBorderWidth
                    simpleList.BorderColor = oldBorderColor
                End Try
                ' If the list is not enabled, call the GetEmptyDesignTimeHtml
                ' method.
            Else
                designTimeHtml = GetEmptyDesignTimeHtml()
            End If
            Return designTimeHtml
        End Function
        Protected Overrides Function GetEmptyDesignTimeHtml() As String
            Dim emptyText As String
            ' Check the CanEnterTemplateMode property to
            ' specify which text to display if ItemTemplate 
            ' does not contain a value.
            If CanEnterTemplateMode Then
                emptyText = _
                    "<b>Either the Enabled property value is false " + _
                    "or you need to set the ItemTemplate for this " + _
                    "control.<br>Right-click to edit templates.</b>"
            Else
                emptyText = _
                    "<b>You cannot edit templates in this view.<br>" + _
                    "Switch to HTML view to define the ItemTemplate.</b>"
            End If
            Return CreatePlaceHolderDesignTimeHtml(emptyText)
        End Function
        ' Generate HTML to indicate that an error has occurred.
        Protected Overrides Function GetErrorDesignTimeHtml(ByVal exc As _
            Exception) As String
            Return CreatePlaceHolderDesignTimeHtml( _
                "<b>An error occurred</b>.<br>Check to ensure that all " + _
                "properties are valid.")
        End Function
        ' Override the Initialize method to ensure that
        ' only an instance of the SimpleDataList class is
        ' used by this designer class.
        Public Overrides Sub Initialize(ByVal component As IComponent)
            simpleList = CType(component, SimpleDataList)
            If IsNothing(simpleList) Then
                Throw New ArgumentException("Must be a SimpleDataList.", "component")
            End If
            MyBase.Initialize(component)
        End Sub
    End Class
End Namespace
下面的示例演示如何使用 DesignerAttribute 属性将设计器与 DataGrid 控件相关联。
' Override the Initialize method to ensure that
' only an instance of the SimpleDataList class is
' used by this designer class.
Public Overrides Sub Initialize(ByVal component As IComponent)
    simpleList = CType(component, SimpleDataList)
    If IsNothing(simpleList) Then
        Throw New ArgumentException("Must be a SimpleDataList.", "component")
    End If
    MyBase.Initialize(component)
End Sub
构造函数
| DataGridDesigner() | 初始化 DataGridDesigner 类的新实例。 | 
属性
| ActionLists | 获取此设计器的设计器操作列表集合。(继承自 BaseDataListDesigner) | 
| ActiveTemplateEditingFrame | 
		已过时.
	 获取活动的模板编辑框。(继承自 TemplatedControlDesigner) | 
| AllowResize | 获取一个值,该值指示是否可以在设计时环境中调整控件的大小。(继承自 ControlDesigner) | 
| AssociatedComponents | 获取与设计器所管理的组件关联的组件集合。(继承自 ComponentDesigner) | 
| AutoFormats | 获取与此设计器关联的 DesignerAutoFormatCollection 对象。 | 
| AutoFormats | 获取预定义自动格式设置方案的集合,这些方案将在设计时显示于关联控件的“自动套用格式”对话框中。(继承自 ControlDesigner) | 
| Behavior | 
		已过时.
	 获取或设置与设计器关联的 DHTML 行为。(继承自 HtmlControlDesigner) | 
| CanEnterTemplateMode | 获取一个值,该值指示此设计器是否允许查看或编辑模板。(继承自 TemplatedControlDesigner) | 
| Component | 获取此设计器正在设计的组件。(继承自 ComponentDesigner) | 
| DataBindings | 获取当前控件的数据绑定集合。(继承自 HtmlControlDesigner) | 
| DataBindingsEnabled | 获取一个值,该值指示设计器是否允许数据绑定。(继承自 TemplatedControlDesigner) | 
| DataKeyField | 获取或设置关联控件的数据键字段的值。(继承自 BaseDataListDesigner) | 
| DataMember | 获取或设置关联控件的数据成员字段的值。(继承自 BaseDataListDesigner) | 
| DataSource | 获取或设置关联控件的数据源属性的值。(继承自 BaseDataListDesigner) | 
| DataSourceDesigner | 获取数据源的设计器(如果已根据数据绑定的需要作了选择)。(继承自 BaseDataListDesigner) | 
| DataSourceID | 获取或设置数据源 ID 属性的设计器版本,然后用来隐藏关联控件的相应属性。(继承自 BaseDataListDesigner) | 
| DesignerState | 获取用于在设计时保持关联控件数据的对象。(继承自 ControlDesigner) | 
| DesignerView | 获取与关联控件绑定的数据源的默认视图。(继承自 BaseDataListDesigner) | 
| DesignTimeElement | 
		已过时.
	 获取一个设计时对象,该对象表示与设计图面上的 HtmlControlDesigner 对象关联的控件。(继承自 HtmlControlDesigner) | 
| DesignTimeElementView | 
		已过时.
	 获取控件设计器的视图控件对象。(继承自 ControlDesigner) | 
| DesignTimeHtmlRequiresLoadComplete | 获取一个值,该值指示是否必须完成加载才能显示设计时标记。(继承自 BaseDataListDesigner) | 
| Expressions | 获取当前控件在设计时的表达式绑定。(继承自 HtmlControlDesigner) | 
| HidePropertiesInTemplateMode | 获取一个值,该值指示当控件被置于模板编辑模式时是否将隐藏控件的属性。(继承自 TemplatedControlDesigner) | 
| ID | 获取或设置控件的 ID 字符串。(继承自 ControlDesigner) | 
| InheritanceAttribute | 获取一个特性,该特性指示关联组件的继承类型。(继承自 ComponentDesigner) | 
| Inherited | 获取一个值,该值指示是否继承此组件。(继承自 ComponentDesigner) | 
| InTemplateMode | 
		已过时.
	 获取一个值,该值指示设计器文档是否处于模板模式。(继承自 TemplatedControlDesigner) | 
| IsDirty | 
		已过时.
	 获取或设置一个值,该值指示 Web 服务器控件是否已被标记为已更改。(继承自 ControlDesigner) | 
| ParentComponent | 获取此设计器的父组件。(继承自 ComponentDesigner) | 
| ReadOnly | 
		已过时.
	 获取或设置一个值,该值指示控件的属性在设计时是否为只读。(继承自 ControlDesigner) | 
| RootDesigner | 获取包含关联控件的 Web 窗体页的控件设计器。(继承自 ControlDesigner) | 
| SetTextualDefaultProperty | 扩展 DataGrid Web 服务器控件的设计时行为。(继承自 ComponentDesigner) | 
| ShadowProperties | 获取重写用户设置的属性值的集合。(继承自 ComponentDesigner) | 
| ShouldCodeSerialize | 
		已过时.
	 获取或设置一个值,该值指示在序列化期间是否应为当前设计文档在代码隐藏文件中创建控件的字段声明。(继承自 HtmlControlDesigner) | 
| Tag | 获取表示关联控件的 HTML 标记元素的对象。(继承自 ControlDesigner) | 
| TemplateGroups | 获取模板组的集合,每个模板组都包含一个模板定义。(继承自 TemplatedControlDesigner) | 
| UsePreviewControl | 获取一个值,该值指示控件设计器是否使用临时预览控件来生成设计时 HTML 标记。(继承自 ControlDesigner) | 
| Verbs | 获取此设计器可用的谓词的集合。(继承自 BaseDataListDesigner) | 
| ViewControl | 获取或设置可用于预览设计时 HTML 标记的 Web 服务器控件。(继承自 ControlDesigner) | 
| ViewControlCreated | 获取或设置一个值,该值指示是否已创建  | 
| Visible | 获取指示该控件在设计时是否可见的值。(继承自 ControlDesigner) |