-3

I have a WPF RichTextBox (rtbControl) and the content as following:

This is not an underlined line
This is an underlined line

I want to underline the 2nd line, how can I do it ?

Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53

2 Answers2

2

Since RTB's content is a FlowDocument, then you have to create appropriate document structure:

    <RichTextBox>
        <FlowDocument>
            <Paragraph>
                <Run Text="This is not an underline line"/>
            </Paragraph>
            <Paragraph>
                <Underline>
                    <Run Text="This is an underline line"/>
                </Underline>
            </Paragraph>
        </FlowDocument>
    </RichTextBox>
Dennis
  • 37,026
  • 10
  • 82
  • 150
-1
<RichTextBox>
    <FlowDocument>
        <Paragraph>
            This is not an underline line
        </Paragraph>     

        <Paragraph>
            <Underline>This is an underline line</Underline>
        </Paragraph>     

    </FlowDocument>       

</RichTextBox>
Wolfgang Ziegler
  • 1,675
  • 11
  • 23