共用方式為


DataGridDesigner.GetDesignTimeHtml 方法

定義

取得用來在設計階段表示 DataGrid 控制項的 HTML 標記。

public:
 override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml ();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String

傳回

用來在設計階段表示 DataGrid 控制項的 HTML 標記。

範例

下列程式代碼範例示範如何覆寫 GetDesignTimeHtml 方法,以改變設計介面上的控件外觀 DataGrid

程式代碼會使用 Try...Catch...Finally 語法來執行下列動作:

  • Try 段會變更數據格控件的屬性值。

  • Catch 段會攔截任何例外狀況,並將其傳送至 GetErrorDesignTimeHtml 方法。

  • Finally 段會將屬性設定為其原始值。

這個範例是提供給 類別之較大範例的 DataGridDesigner 一部分。

' 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

適用於

另請參閱