DataGridDesigner.GetDesignTimeHtml 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得設計時用來表示 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