TableDesigner 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擴充了網頁伺服器控制的設計時行為 Table 。
public ref class TableDesigner : System::Web::UI::Design::ControlDesigner
public class TableDesigner : System.Web.UI.Design.ControlDesigner
[System.Web.UI.Design.SupportsPreviewControl(true)]
public class TableDesigner : System.Web.UI.Design.ControlDesigner
type TableDesigner = class
inherit ControlDesigner
[<System.Web.UI.Design.SupportsPreviewControl(true)>]
type TableDesigner = class
inherit ControlDesigner
Public 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
建構函式
| 名稱 | Description |
|---|---|
| TableDesigner() |
初始化 TableDesigner 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| 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 |
已淘汰.
取得或設定一個值,表示網頁伺服器控制項是否被標記為變更。 (繼承來源 ControlDesigner) |
| ParentComponent |
取得這個設計器的父元件。 (繼承來源 ComponentDesigner) |
| ReadOnly |
已淘汰.
取得或設定一個值,表示控制項屬性在設計時是否為唯讀。 (繼承來源 ControlDesigner) |
| RootDesigner |
取得包含相關控制項的網頁表單頁面的控制項設計器。 (繼承來源 ControlDesigner) |
| ShadowProperties |
會取得一組屬性值,覆蓋使用者設定。 (繼承來源 ComponentDesigner) |
| ShouldCodeSerialize |
已淘汰.
在序列化過程中,會取得或設定一個值,指示是否要在目前設計文件的程式碼背後檔案中為控制項建立欄位宣告。 (繼承來源 HtmlControlDesigner) |
| Tag |
取得一個代表相關控制項 HTML 標記元素的物件。 (繼承來源 ControlDesigner) |
| TemplateGroups |
獲得一組模板群組,每個群組包含一個或多個範本定義。 (繼承來源 ControlDesigner) |
| UsePreviewControl |
會取得一個值,指示控制項設計者是否使用暫存預覽控制來產生設計時的 HTML 標記。 (繼承來源 ControlDesigner) |
| Verbs |
取得與設計者相關元件所支援的設計時動詞。 (繼承來源 ComponentDesigner) |
| ViewControl |
取得或設定一個網頁伺服器控制項,可用於預覽設計時的 HTML 標記。 (繼承來源 ControlDesigner) |
| ViewControlCreated |
取得或設定一個值,指示是否 |
| Visible |
會獲得一個值,表示該控制點在設計時是否可見。 (繼承來源 ControlDesigner) |
方法
明確介面實作
| 名稱 | Description |
|---|---|
| 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) |