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