MenuDesigner.GetDesignTimeHtml Método

Definição

Obtém a marcação usada para renderizar o controle associado em tempo de design.Gets the markup that is used to render the associated control at design time.

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

Retornos

String

Uma cadeia de caracteres que contém a marcação usada para renderizar o Menu em tempo de design.A string containing the markup used to render the Menu at design time.

Exemplos

O exemplo de código a seguir mostra como substituir o GetDesignTimeHtml método em uma classe que é herdada da MenuDesigner classe.The following code example shows how to override the GetDesignTimeHtml method in a class that is inherited from the MenuDesigner class. O método substituído altera a aparência de um controle que é derivado do Menu controle em tempo de design.The overridden method changes the appearance of a control that is derived from the Menu control at design time. O exemplo desenha uma borda laranja e pontilhada em torno do controle para tornar sua extensão mais visível, se a BorderStyle Propriedade do controle for o NotSet None valor ou.The example draws an orange, dotted border around the control to make its extent more visible, if the BorderStyle property of the control is the NotSet or None value.

// 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

Comentários

O GetDesignTimeHtml método chama o DataBind método para associar a fonte de dados de tempo de design ao Menu controle associado e, em seguida, GetDesignTimeHtml chama o GetDesignModeState método para fazer com que o Menu controle gere sua marcação de exibição estática e dinâmica.The GetDesignTimeHtml method calls the DataBind method to bind the design-time data source to the associated Menu control, and then the GetDesignTimeHtml calls the GetDesignModeState method to cause the Menu control to generate its static-view and dynamic-view markup. O GetDesignTimeHtml retorna a marcação para a exibição atual.The GetDesignTimeHtml returns the markup for the current view. Se o modo de exibição atual não estiver definido, o GetDesignTimeHtml chamará o GetDesignTimeHtml método base.If the current view is not defined, the GetDesignTimeHtml calls the GetDesignTimeHtml base method.

Aplica-se a

Confira também