MenuDesigner.GetDesignTimeHtml Metodo

Definizione

Ottiene il markup usato per il rendering del controllo associato in fase di progettazione.

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

Restituisce

Stringa contenente il markup utilizzato per eseguire il rendering dell'oggetto Menu in fase di progettazione.

Esempio

Nell'esempio di codice seguente viene illustrato come eseguire l'override del GetDesignTimeHtmlMenuDesigner metodo in una classe ereditata dalla classe. Il metodo sottoposto a override modifica l'aspetto Menu di un controllo derivato dal controllo in fase di progettazione. L'esempio disegna un bordo arancione, punteggiato intorno al controllo per rendere più visibile l'estensione, se la BorderStyle proprietà del controllo è il NotSet valore o 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

Commenti

Il GetDesignTimeHtml metodo chiama il DataBind metodo per associare l'origine dati in fase di progettazione al controllo associato Menu e quindi GetDesignTimeHtml chiama il GetDesignModeState metodo per generare il Menu markup statico e di visualizzazione dinamica. Restituisce GetDesignTimeHtml il markup per la visualizzazione corrente. Se la visualizzazione corrente non è definita, il GetDesignTimeHtml metodo chiama il GetDesignTimeHtml metodo di base.

Si applica a

Vedi anche