所以我有一个富文本框,我试图得到最后一行可见行中第一个字符的索引,但我有一个问题。
我正在尝试使用以下方法检索索引:
int lastVisibleCharIndex= messageEditorRtb.GetCharIndexFromPosition(new Point(0, messageEditorRtb.Height));
int lastVisibleLine= messageEditorRtb.GetLineFromCharIndex(lastVisibleCharIndex);
if (lastVisibleLine>= messageEditorRtb.Lines.Length) return;
在我尝试检索富文本框中最后两行的索引之前,这是有效的。无论最后一行是最后一行还是最后一行,我总是得到相同的lastVisibleCharIndex值,我不知道为什么会这样。有没有人建议如何在富文本框中获取最后一行?
我收录了我的问题图片,以帮助解释它。
最后一行应返回大于倒数第二行的索引。有人能看出为什么会这样吗?
感谢。