Share via


MenuDesigner.GetDesignTimeHtml Méthode

Définition

Obtient le balisage utilisé pour afficher le contrôle associé au moment de la conception.

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

Retours

Chaîne qui contient le balisage utilisé pour rendre Menu au moment du design.

Exemples

L’exemple de code suivant montre comment remplacer la GetDesignTimeHtml méthode dans une classe héritée de la MenuDesigner classe . La méthode remplacée modifie l’apparence d’un contrôle dérivé du contrôle au moment de la Menu conception. L’exemple dessine une bordure orange en pointillés autour du contrôle pour rendre son étendue plus visible, si la BorderStyle propriété du contrôle est la NotSet valeur ou None .

// Generate the design-time markup.
public override string GetDesignTimeHtml()
{
    // Make the control more visible in the designer.  If the border 
    // style is None or NotSet, change the border to an orange dotted line. 
    MyMenu myMenuCtl = (MyMenu)ViewControl;
    string markup = null;

    // Check if the border style should be changed.
    if (myMenuCtl.BorderStyle == BorderStyle.NotSet ||
        myMenuCtl.BorderStyle == BorderStyle.None)
    {
        BorderStyle oldBorderStyle = myMenuCtl.BorderStyle;
        Color oldBorderColor = myMenuCtl.BorderColor;

        // Set the design-time properties and catch any exceptions.
        try
        {
            myMenuCtl.BorderStyle = BorderStyle.Dotted;
            myMenuCtl.BorderColor = Color.FromArgb(0xFF7F00);

            // Call the base method to generate the markup.
            markup = base.GetDesignTimeHtml();
        }
        catch (Exception ex)
        {
            markup = GetErrorDesignTimeHtml(ex);
        }
        finally
        {
            // Restore the properties to their original settings.
            myMenuCtl.BorderStyle = oldBorderStyle;
            myMenuCtl.BorderColor = oldBorderColor;
        }
    }
    else
    {
        // Call the base method to generate the markup.
        markup = base.GetDesignTimeHtml();
    }

    return markup;
} // GetDesignTimeHtml
' Generate the design-time markup.
Public Overrides Function GetDesignTimeHtml() As String

    ' Make the control more visible in the designer.  If the border 
    ' style is None or NotSet, change the border to an orange dotted line. 
    Dim myMenuCtl As MyMenu = CType(ViewControl, MyMenu)
    Dim markup As String = Nothing

    ' Check if the border style should be changed.
    If (myMenuCtl.BorderStyle = BorderStyle.NotSet Or _
        myMenuCtl.BorderStyle = BorderStyle.None) Then

        Dim oldBorderStyle As BorderStyle = myMenuCtl.BorderStyle
        Dim oldBorderColor As Color = myMenuCtl.BorderColor

        ' Set the design-time properties and catch any exceptions.
        Try
            myMenuCtl.BorderStyle = BorderStyle.Dotted
            myMenuCtl.BorderColor = Color.FromArgb(&HFF7F00)

            ' Call the base method to generate the markup.
            markup = MyBase.GetDesignTimeHtml()

        Catch ex As Exception
            markup = GetErrorDesignTimeHtml(ex)

        Finally
            ' Restore the properties to their original settings.
            myMenuCtl.BorderStyle = oldBorderStyle
            myMenuCtl.BorderColor = oldBorderColor
        End Try

    Else
        ' Call the base method to generate the markup.
        markup = MyBase.GetDesignTimeHtml()
    End If

    Return markup

End Function ' GetDesignTimeHtml

Remarques

La GetDesignTimeHtml méthode appelle la DataBind méthode pour lier la source de données au moment du design au contrôle associé Menu , puis appelle la GetDesignTimeHtmlGetDesignModeState méthode pour que le Menu contrôle génère son balisage d’affichage statique et dynamique. GetDesignTimeHtml retourne le balisage de l’affichage actuel. Si l’affichage actuel n’est pas défini, le GetDesignTimeHtml appelle la méthode de GetDesignTimeHtml base.

S’applique à

Voir aussi