次の方法で共有


DataGridDesigner.GetDesignTimeHtml メソッド

デザイン時にコントロールを表すために使用する HTML を取得します。

Overrides Public Function GetDesignTimeHtml() As String
[C#]
public override string GetDesignTimeHtml();
[C++]
public: String* GetDesignTimeHtml();
[JScript]
public override function GetDesignTimeHtml() : String;

戻り値

デザイン時にコントロールを表すために使用する HTML。

使用例

[Visual Basic] GetDesignTimeHtml メソッドをオーバーライドして、 WebControl.BorderStyle プロパティに値が設定されていない場合に SimpleDataGrid クラスの表示関連プロパティを設定および表示するコード例を次に示します。このコードでは、各プロパティへの値の設定に Try...Catch...Finally 構文を使用してします。つまり、 Try セクションで BorderColorBorderWidthCellPadding の各プロパティの値を設定し、 Catch セクションで、発生した例外をキャッチして GetErrorDesignTimeHtml メソッドに送信し、 Finally セクションで各プロパティの値を元に戻します。

[Visual Basic] このコード例は、 DataGridDesigner クラスのトピックで取り上げているコード例の一部分です。

 
' Override the GetDesignTimeHtml method.
Public Overrides Function GetDesignTimeHtml() As String

   Dim designTimeHtml As String = Nothing      
   
   ' Check the control's BorderStyle property
   ' to conditionally render design-time HTML.
   If (simpleGrid.BorderStyle = BorderStyle.NotSet) Then

       ' Create variables to hold current property settings.
       Dim oldCellPadding As Integer = simpleGrid.CellPadding
       Dim oldBorderWidth As Unit = simpleGrid.BorderWidth
       Dim oldBorderColor As Color = simpleGrid.BorderColor
       
       ' Set properties and the design-time HTML.
       Try
           simpleGrid.CellPadding = 1
           simpleGrid.BorderWidth = Unit.Pixel(3)
           simpleGrid.BorderColor = Color.Brown
           designTimeHtml = MyBase.GetDesignTimeHtml()
             
       ' If an exception occurs, call the GetErrorDesignTimeHtml
       ' method.
       Catch ex As Exception
           designTimeHtml = GetErrorDesignTimeHtml(ex)

       ' Return properties to their original settings.
       Finally
           simpleGrid.CellPadding = oldCellPadding
           simpleGrid.BorderWidth = oldBorderWidth
           simpleGrid.BorderColor = oldBorderColor
       End Try
       
   Else
       designTimeHtml = MyBase.GetDesignTimeHtml()
   End If
   
   Return designTimeHTML

End Function 

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

DataGridDesigner クラス | DataGridDesigner メンバ | System.Web.UI.Design.WebControls 名前空間