RichTextBox用户可以选择向前或向后的文本。如何以编程方式确定选择的方向?(的LogicalDirection和End并不Start表示这一点)
1 回答
沧海一幻觉
TA贡献1824条经验 获得超5个赞
您可以将CaretPosition与当前进行比较Selection以确定选择文本的方向:
TextPointer caretPos = richTextBox.CaretPosition;
TextPointer selectStart = richTextBox.Selection.Start;
TextPointer selectEnd = richTextBox.Selection.End;
if(caretPos.CompareTo(selectStart) == 0)
{
//The text was selected from right to left.
}
else if(caretPos.CompareTo(selectEnd) == 0)
{
//The text was selected from left to right.
}
- 1 回答
- 0 关注
- 96 浏览
添加回答
举报
0/150
提交
取消