TableDesigner 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
扩展 Table Web 服务器控件的设计时行为。
public ref class TableDesigner : System::Web::UI::Design::ControlDesignerpublic class TableDesigner : System.Web.UI.Design.ControlDesigner[System.Web.UI.Design.SupportsPreviewControl(true)]
public class TableDesigner : System.Web.UI.Design.ControlDesignertype TableDesigner = class
    inherit ControlDesigner[<System.Web.UI.Design.SupportsPreviewControl(true)>]
type TableDesigner = class
    inherit ControlDesignerPublic Class TableDesigner
Inherits ControlDesigner- 继承
- 属性
示例
该部分包含两个代码示例。 第一个代码示例演示如何从 TableDesigner 类派生类。 第二个代码示例演示如何在设计时显示 StyledTable 类。
下面的代码示例演示如何创建一个名为 StyledTableDesigner的设计器类,该类派生自 TableDesigner 类,用于在设计时为派生自 类 Table 的类显示两个单元格。
' Create a class, named StyledTableDesigner,
' that derives from the TableDesigner class.
' This class displays a class named StyledTable
' at design time.
Public Class StyledTableDesigner
   Inherits TableDesigner
   
   ' Override the GetDesignTimeHtml method to display
   ' placeholder text at design time for the 
   ' rows and cells of the StyledTable class.
   Public Overrides Function GetDesignTimeHtml() As String
       Dim sTable As StyledTable = CType(Component, StyledTable)
       Dim designTimeHTML As String
       Dim rows As TableRowCollection = sTable.Rows
       Dim cellsWithDummyContents As ArrayList = Nothing
      
       Dim emptyTable As Boolean = rows.Count = 0
       Dim emptyRows As Boolean = False
       Dim counter As Integer = 1
       Dim numcells As Integer = 2
       
       Try     
           ' Create two cells to display
           ' in a row at design time.
           If emptyTable Then
               Dim row As TableRow = New TableRow()
               rows.Add(row)
         
               Dim i As Integer
               For i = 0 To numcells - 1
                   Dim c As TableCell = New TableCell()
                   c.Text = "Cell #" & counter.ToString()
                   counter += 1
                   rows(0).Cells.Add(c)
               Next i
           Else
               emptyRows = True
               Dim j As Integer
               For j = 0 To rows.Count - 1
                   If rows(j).Cells.Count <> 0 Then
                       emptyRows = False
                       Exit For
                   End If
               Next j
               If emptyRows = True Then
                   Dim k As Integer
                   For k = 0 To numcells - 1
                       Dim c As TableCell = New TableCell()
                       c.Text = "Cell #" & counter.ToString()
                       counter += 1
                       rows(0).Cells.Add(c)
                   Next k
                End If
           End If
      
           If emptyTable = False Then
               ' If the rows and cells were defined by the user, but the
               ' cells remain empty this code defines a string to display 
               ' in them at design time.
               Dim row As TableRow
               For Each row In rows
                   Dim c As TableCell
                   For Each c In row.Cells
                       If ((c.Text.Length = 0) AndAlso (c.HasControls() = False)) Then
                          If cellsWithDummyContents Is Nothing Then
                              cellsWithDummyContents = New ArrayList()
                          End If
                          cellsWithDummyContents.Add(c)
                          c.Text = "Cell #" & counter.ToString()
                          counter += 1
                       End If
                   Next c
               Next row
           End If
           ' Retrieve the design-time HTML for the StyledTable class.
           designTimeHTML = MyBase.GetDesignTimeHtml()
       Finally
           ' If the StyledTable was empty before the dummy text was added,
           ' restore it to that state.
           If emptyTable Then
               rows.Clear()
           Else
               ' Clear the cells that were empty before the dummy text 
               ' was added.
               If Not (cellsWithDummyContents Is Nothing) Then
                   Dim c As TableCell
                   For Each c In  cellsWithDummyContents
                       c.Text = [String].Empty
                   Next c
               End If
               If emptyRows Then
                   rows(0).Cells.Clear()
               End If
           End If
      
       End Try
       Return designTimeHTML
   End Function
End Class
下面的代码示例使用 DesignerAttribute 将 类与 类相关联 StyledTableDesigner , StyledTable 以便在设计时显示它。
 ' Create a class that uses the StyledTableDesigner
 ' class to display its contents at design time.
<Designer("Examples.AspNet.Design.StyledTableDesigner", "TableDesigner")> _
Public Class StyledTable
  Inherits Table 
    
    Private tableStyle As Style = New Style()
    
    Public Sub New()
       tableStyle.BackColor = Color.LightBlue
       tableStyle.BorderColor = Color.Black
       
       CellSpacing = 4
       CellPadding = 0
       GridLines = GridLines.None
       BorderWidth = Unit.Point(1)
       Width = Unit.Percentage(100)
       Height = Unit.Percentage(100)
    End Sub
End Class
构造函数
| TableDesigner() | 初始化 TableDesigner 类的新实例。 | 
属性
| ActionLists | 获取控件设计器的操作列表集合。(继承自 ControlDesigner) | 
| AllowResize | 获取一个值,该值指示是否可以在设计时环境中调整控件的大小。(继承自 ControlDesigner) | 
| AssociatedComponents | 获取与设计器所管理的组件关联的组件集合。(继承自 ComponentDesigner) | 
| AutoFormats | 获取预定义自动格式设置方案的集合,这些方案将在设计时显示于关联控件的“自动套用格式”对话框中。(继承自 ControlDesigner) | 
| Behavior | 
		已过时.
	 获取或设置与设计器关联的 DHTML 行为。(继承自 HtmlControlDesigner) | 
| Component | 获取此设计器正在设计的组件。(继承自 ComponentDesigner) | 
| DataBindings | 获取当前控件的数据绑定集合。(继承自 HtmlControlDesigner) | 
| DataBindingsEnabled | 获取一个值,该值指示包含关联控件的区域是否支持数据绑定。(继承自 ControlDesigner) | 
| DesignerState | 获取用于在设计时保持关联控件数据的对象。(继承自 ControlDesigner) | 
| DesignTimeElement | 
		已过时.
	 获取一个设计时对象,该对象表示与设计图面上的 HtmlControlDesigner 对象关联的控件。(继承自 HtmlControlDesigner) | 
| DesignTimeElementView | 
		已过时.
	 获取控件设计器的视图控件对象。(继承自 ControlDesigner) | 
| DesignTimeHtmlRequiresLoadComplete | 
		已过时.
	 获取一个值,该值指示是否必须在设计宿主完成加载之后才能调用 GetDesignTimeHtml 方法。(继承自 ControlDesigner) | 
| Expressions | 获取当前控件在设计时的表达式绑定。(继承自 HtmlControlDesigner) | 
| HidePropertiesInTemplateMode | 获取一个值,该值指示当控件处于模板模式时,关联控件的属性是否被隐藏。(继承自 ControlDesigner) | 
| ID | 获取或设置控件的 ID 字符串。(继承自 ControlDesigner) | 
| InheritanceAttribute | 获取一个特性,该特性指示关联组件的继承类型。(继承自 ComponentDesigner) | 
| Inherited | 获取一个值,该值指示是否继承此组件。(继承自 ComponentDesigner) | 
| InTemplateMode | 获取一个值,该值指示控件在设计宿主中是否处于模板查看模式或模板编辑模式之一。 InTemplateMode 属性为只读。(继承自 ControlDesigner) | 
| IsDirty | 
		已过时.
	 获取或设置一个值,该值指示 Web 服务器控件是否已被标记为已更改。(继承自 ControlDesigner) | 
| ParentComponent | 获取此设计器的父组件。(继承自 ComponentDesigner) | 
| ReadOnly | 
		已过时.
	 获取或设置一个值,该值指示控件的属性在设计时是否为只读。(继承自 ControlDesigner) | 
| RootDesigner | 获取包含关联控件的 Web 窗体页的控件设计器。(继承自 ControlDesigner) | 
| SetTextualDefaultProperty | 扩展 Table Web 服务器控件的设计时行为。(继承自 ComponentDesigner) | 
| ShadowProperties | 获取重写用户设置的属性值的集合。(继承自 ComponentDesigner) | 
| ShouldCodeSerialize | 
		已过时.
	 获取或设置一个值,该值指示在序列化期间是否应为当前设计文档在代码隐藏文件中创建控件的字段声明。(继承自 HtmlControlDesigner) | 
| Tag | 获取表示关联控件的 HTML 标记元素的对象。(继承自 ControlDesigner) | 
| TemplateGroups | 获取一个模板组集合,其中每个模板组包含一个或多个模板定义。(继承自 ControlDesigner) | 
| UsePreviewControl | 获取一个值,该值指示控件设计器是否使用临时预览控件来生成设计时 HTML 标记。(继承自 ControlDesigner) | 
| Verbs | 获取与设计器相关联的组件所支持的设计时谓词。(继承自 ComponentDesigner) | 
| ViewControl | 获取或设置可用于预览设计时 HTML 标记的 Web 服务器控件。(继承自 ControlDesigner) | 
| ViewControlCreated | 获取或设置一个值,该值指示是否已创建  | 
| Visible | 获取指示该控件在设计时是否可见的值。(继承自 ControlDesigner) | 
方法
显式接口实现
| IDesignerFilter.PostFilterAttributes(IDictionary) | 有关此成员的说明,请参见 PostFilterAttributes(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PostFilterEvents(IDictionary) | 有关此成员的说明,请参见 PostFilterEvents(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PostFilterProperties(IDictionary) | 有关此成员的说明,请参见 PostFilterProperties(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterAttributes(IDictionary) | 有关此成员的说明,请参见 PreFilterAttributes(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterEvents(IDictionary) | 有关此成员的说明,请参见 PreFilterEvents(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterProperties(IDictionary) | 有关此成员的说明,请参见 PreFilterProperties(IDictionary) 方法。(继承自 ComponentDesigner) | 
| ITreeDesigner.Children | 有关此成员的说明,请参见 Children 属性。(继承自 ComponentDesigner) | 
| ITreeDesigner.Parent | 有关此成员的说明,请参见 Parent 属性。(继承自 ComponentDesigner) |