1

在此处输入图像描述

<RichTextBox Name="rtb" Margin="20">
    <FlowDocument>
        <Paragraph>Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow.</Paragraph>
        <Table CellSpacing="10"
               Padding="0"
               Background="Yellow"
               FontFamily="Arial"
               FontSize="12">
            <Table.Columns>
                <TableColumn Width="70" />
                <TableColumn Width="120" />
                <TableColumn Width="200" />
            </Table.Columns>
            <TableRowGroup Background="Gold">
                <TableRow>
                    <TableCell ColumnSpan="3">
                        <Paragraph Foreground="Gold" Background="Black" TextAlignment="Center" FontSize="16">Table Header</Paragraph>
                    </TableCell>
                </TableRow>
                <TableRow>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,0</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,1</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,2</Paragraph>
                    </TableCell>
                </TableRow>
                <TableRow>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,0</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,1</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,2</Paragraph>
                    </TableCell>
                </TableRow>
            </TableRowGroup>
        </Table>
        <Paragraph>Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow.</Paragraph>
    </FlowDocument>
</RichTextBox>

对于 FindAgain,我需要TextRange从选择结束到文档结尾:

string rangeText = new TextRange(rtb.Selection.End, rtb.Document.ContentEnd).Text;

我希望 rangeText 以“1,1”开头,但它以“Cell 1,0”开头。对我来说似乎很奇怪,但是,我怎样才能获得所需的范围?

4

0 回答 0