Html32TextWriter.SupportsBold 속성

정의

요청 디바이스에서 굵은 HTML 텍스트를 지원하는지 여부를 나타내는 부울 값을 가져오거나 설정합니다. 속성을 SupportsBold 사용하여 굵은 텍스트를 출력 스트림에 조건부로 렌더링합니다 Html32TextWriter .

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

속성 값

true요청 디바이스에서 굵은 텍스트를 지원하면 이고, 그렇지 않으면 . false 기본값은 true입니다.

예제

다음 코드 예제에서는 및 RenderBeforeContent 메서드를 재정의하는 RenderAfterContent 방법을 보여 줍니다. 각 재정의는 요소가 렌더링되고 있는지 여부를 Label 확인한 다음, 메서드를 사용하여 SupportsBold 요청 디바이스에 굵게 서식을 표시할 수 있는지 여부를 확인합니다. 디바이스에서 굵게 서식을 지원하는 경우 메서드는 RenderBeforeContent 요소의 여는 태그를 b 쓰고 메서드는 RenderAfterContent 닫는 태그를 씁니다. 디바이스에서 굵게 서식을 RenderBeforeContent 지원하지 않는 경우 메서드는 특성이 설정된 요소 Fontcolor 여는 태그를 빨강의 16진수 값으로 쓰고 메서드는 RenderAfterContent 닫는 태그를 씁니다.

이 코드 예제는 클래스에 제공된 더 큰 예제의 Html32TextWriter 일부입니다.

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

적용 대상

추가 정보