MenuDesigner.GetDesignTimeHtml Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém a marcação que é usada para renderizar o controlo associado no momento do design.
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
Devoluções
Uma string contendo a marcação usada para renderizar o Menu momento do design.
Exemplos
O exemplo de código seguinte mostra como sobrescrever o GetDesignTimeHtml método numa classe que é herdada da MenuDesigner classe. O método sobreposto altera a aparência de um controlo que é derivado do Menu controlo no momento do projeto. O exemplo desenha uma borda laranja pontilhada em redor do controlo para tornar a sua extensão mais visível, se a BorderStyle propriedade do controlo for o NotSet valor 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
Observações
O GetDesignTimeHtml método chama o DataBind método para ligar a fonte de dados em tempo de projeto ao controlo associado Menu , e depois GetDesignTimeHtml chama o GetDesignModeState método para fazer com que o Menu controlo gere a sua marcação em vista estática e dinâmica. Devolve GetDesignTimeHtml a marcação para a visualização atual. Se a vista atual não estiver definida, chama GetDesignTimeHtml o GetDesignTimeHtml método base.