次の方法で共有


CheckBoxDesigner.GetDesignTimeHtml メソッド

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

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

戻り値

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

解説

Text プロパティが空の場合、このメソッドは、コントロールの Text プロパティをコントロールの Control.ID プロパティに設定します。

使用例

[Visual Basic] GetDesignTimeHtml メソッドをオーバーライドするコード例を次に示します。 CheckBox.Text プロパティが設定済みでない場合は、このメソッドを呼び出すと、プロパティに文字列が設定され、デザイン画面にその文字列が表示されます。 Text プロパティに値が既に設定されている場合は、その値が表示されます。

 
' Override the GetDesignTimeHtml method to display
' display a border on the control if the BorderStyle
' property has not been set by the user.
<System.Security.Permissions.SecurityPermission( _
  System.Security.Permissions.SecurityAction.Demand, _
  Flags := System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Public Class SampleCheckBoxDesigner
    Inherits CheckBoxDesigner

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

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

            ' Create variables to hold current property settings.
            Dim oldBorderStyle As BorderStyle = sampleCheckBox.BorderStyle
            
           ' Set properties and the design-time HTML.
            Try
                sampleCheckBox.BorderStyle = BorderStyle.Groove
            
                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
                sampleCheckBox.BorderStyle = oldBorderStyle
            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 セキュリティ:

参照

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