ListControlDesigner.GetDesignTimeHtml Methode

Definitie

Hiermee haalt u de HTML op die wordt gebruikt om het besturingselement tijdens het ontwerp aan te geven.

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

Retouren

Een String met de opmaak die wordt gebruikt om het besturingselement weer te geven dat is afgeleid van het ListControl ontwerp.

Voorbeelden

In het volgende codevoorbeeld wordt de GetDesignTimeHtml methode overschreven om de opmaak aan te passen die wordt weergegeven voor het bijbehorende besturingselement op een ontwerpoppervlak. Als de BackColor eigenschap niet is gedefinieerd voor het bijbehorende besturingselement, wordt deze ingesteld op Gainsboroen wordt het besturingselement weergegeven met die achtergrondkleur. Nadat dit is gebeurd, wordt de basisuitvoering van de GetDesignTimeHtml methode aangeroepen.

Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de ListControlDesigner klasse.

// Create the markup to display the control on the design surface. 
public override string GetDesignTimeHtml()
{
    string designTimeMarkup = null;

    // Create variables to access the control
    // item collection and back color.
    ListItemCollection items = simpleRadioButtonList.Items;
    Color oldBackColor = simpleRadioButtonList.BackColor;

    // Check the property values and render the markup
    // on the design surface accordingly.
    try
    {
        if (oldBackColor == Color.Empty)
            simpleRadioButtonList.BackColor = Color.Gainsboro;

        if (changedDataSource)
            items.Add("Updated to a new data source: " + 
                DataSource + ".");

        // Call the base method to generate the markup.
        designTimeMarkup = base.GetDesignTimeHtml();
    }
    catch (Exception ex)
    {
        // Catch any exceptions that occur.
        designTimeMarkup = GetErrorDesignTimeHtml(ex);
    }
    finally
    {
        // Set the properties back to their original state.
        simpleRadioButtonList.BackColor = oldBackColor;
        items.Clear();
    }

    return designTimeMarkup;
} // GetDesignTimeHtml
' Create the markup to display the control on the design surface.
Public Overrides Function GetDesignTimeHtml() As String

    Dim designTimeHtml As String = String.Empty

    ' Create variables to access the control's
    ' item collection and back color. 
    Dim items As ListItemCollection = simpleRadioButtonList.Items
    Dim oldBackColor As Color = simpleRadioButtonList.BackColor

    ' Check the property values and render the markup
    ' on the design surface accordingly.
    Try
        If (Color.op_Equality(oldBackColor, Color.Empty)) Then
            simpleRadioButtonList.BackColor = Color.Gainsboro
        End If

        If (changedDataSource) Then
            items.Add( _
                "Updated to a new data source: " & DataSource & ".")
        End If

        designTimeHtml = MyBase.GetDesignTimeHtml()

    Catch ex As Exception
        ' Catch any exceptions that occur.
        MyBase.GetErrorDesignTimeHtml(ex)

    Finally
        ' Set the properties back to their original state.
        simpleRadioButtonList.BackColor = oldBackColor
        items.Clear()
    End Try

    Return designTimeHtml
End Function ' GetDesignTimeHtml

Opmerkingen

Als het bijbehorende besturingselement dat is afgeleid van het ListControl object gegevensgebonden is, wist de GetDesignTimeHtml methode de Items verzameling en voegt een String bericht toe dat aangeeft dat het besturingselement gegevensgebonden is. Als het gekoppelde besturingselement geen gegevensgrens is en de Items verzameling leeg is, GetDesignTimeHtml wordt er een String bericht toegevoegd dat aangeeft dat het besturingselement niet afhankelijk is. Vervolgens wordt de GetDesignTimeHtml basismethode aangeroepen om de opmaak te genereren.

Van toepassing op

Zie ook