CheckBoxDesigner.GetDesignTimeHtml Metod

Definition

Hämtar den markering som används för att representera kontrollen vid designtillfället.

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

Returer

Den markering som används för att representera kontrollen vid designtillfället.

Exempel

I följande kodexempel åsidosätts GetDesignTimeHtml metoden. Om egenskapen CheckBox.Text inte har angetts tidigare, anger ett anrop till den här metoden den till en sträng och visar strängen på designytan. Om egenskapen Text redan har angetts visas det befintliga egenskapsvärdet.

' Override the GetDesignTimeHtml method to display a border on the 
' control if the BorderStyle property has not been set by the user.
Public Overrides Function GetDesignTimeHtml() As String

    Dim sampleCheckBox As SampleCheckBox = CType(Component, _
        SampleCheckBox)
    Dim designTimeHtml As String = Nothing

    ' Check the control's BorderStyle property.
    If (sampleCheckBox.BorderStyle = BorderStyle.NotSet) Then

        ' Save the current value of the BorderStyle property.
        Dim oldBorderStyle As BorderStyle = _
            sampleCheckBox.BorderStyle

        ' Change the value of the BorderStyle property and 
        ' generate 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)

            ' Restore the BorderStyle property to its original value.
        Finally
            sampleCheckBox.BorderStyle = oldBorderStyle
        End Try

    Else
        designTimeHtml = MyBase.GetDesignTimeHtml()
    End If

    Return designTimeHtml
End Function

Kommentarer

Om egenskapen Text är tom eller endast består av tomt utrymme innehåller ID den genererade HTML-koden kryssrutans kontroll. Annars innehåller den genererade HTML-koden innehållet i kontrollens Text egenskap.

Åsidosätt den här metoden för att ändra den genererade HTML-koden.

Gäller för

Se även