Html32TextWriter.SupportsBold Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit une valeur booléenne indiquant si l’appareil demandeur prend en charge le texte HTML en gras. Utilisez la SupportsBold propriété pour afficher de manière conditionnelle du texte en gras dans le flux de Html32TextWriter sortie.
public:
property bool SupportsBold { bool get(); void set(bool value); };
public bool SupportsBold { get; set; }
member this.SupportsBold : bool with get, set
Public Property SupportsBold As Boolean
Valeur de propriété
true si l’appareil demandeur prend en charge le texte en gras ; sinon, false. La valeur par défaut est true.
Exemples
L’exemple de code suivant montre comment remplacer les méthodes et RenderBeforeContent les RenderAfterContent méthodes. Chaque remplacement vérifie si un Label élément est affiché, puis utilise la SupportsBold méthode pour vérifier si l’appareil demandeur peut afficher une mise en forme en gras. Si l’appareil prend en charge la mise en forme en gras, la RenderBeforeContent méthode écrit la balise d’ouverture d’un b élément et la RenderAfterContent méthode écrit sa balise fermante. Si l’appareil ne prend pas en charge la mise en forme en gras, la RenderBeforeContent méthode écrit la balise d’ouverture d’un Font élément avec un color attribut défini sur la valeur hexadécimale pour rouge et la RenderAfterContent méthode écrit la balise fermante.
Cet exemple de code fait partie d’un exemple plus grand fourni pour la Html32TextWriter classe.
// Override the RenderBeforeContent method to render
// styles before rendering the content of a <th> element.
protected override string RenderBeforeContent()
{
// Check the TagKey property. If its value is
// HtmlTextWriterTag.TH, check the value of the
// SupportsBold property. If true, return the
// opening tag of a <b> element; otherwise, render
// the opening tag of a <font> element with a color
// attribute set to the hexadecimal value for red.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "<b>";
else
return "<font color=\"FF0000\">";
}
// Check whether the element being rendered
// is an <H4> element. If it is, check the
// value of the SupportsItalic property.
// If true, render the opening tag of the <i> element
// prior to the <H4> element's content; otherwise,
// render the opening tag of a <font> element
// with a color attribute set to the hexadecimal
// value for navy blue.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "<i>";
else
return "<font color=\"000080\">";
}
// Call the base method.
return base.RenderBeforeContent();
}
' Override the RenderBeforeContent method to render
' styles before rendering the content of a <th> element.
Protected Overrides Function RenderBeforeContent() As String
' Check the TagKey property. If its value is
' HtmlTextWriterTag.TH, check the value of the
' SupportsBold property. If true, return the
' opening tag of a <b> element; otherwise, render
' the opening tag of a <font> element with a color
' attribute set to the hexadecimal value for red.
If TagKey = HtmlTextWriterTag.Th Then
If (SupportsBold) Then
Return "<b>"
Else
Return "<font color=""FF0000"">"
End If
End If
' Check whether the element being rendered
' is an <H4> element. If it is, check the
' value of the SupportsItalic property.
' If true, render the opening tag of the <i> element
' prior to the <H4> element's content; otherwise,
' render the opening tag of a <font> element
' with a color attribute set to the hexadecimal
' value for navy blue.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "<i>"
Else
Return "<font color=""000080"">"
End If
End If
' Call the base method.
Return MyBase.RenderBeforeContent()
End Function