C# .NET RichTextBox GetCharOffsetFromPosition?
有没有办法获得字符相对于某个位置的偏移量?
我有一个看起来像这样的框 -
我想逐个字符地解析它 但我想检测它何时是上标(我通过将 SelectionCharOffset 设置为 10 来实现
我所拥有的是一个看起来像的循环这样我就可以使用 i 访问该位置
for (int i = 0; i < Text1.TextLength; i++) {
//I can use things here like Text1.Text[i]...
}
Is there a way to get character offset from a position?
I have a box that looks like this -
I want to parse it character by character but I want to detect when it is superscript (which I achieved by setting SelectionCharOffset to 10
What I have is a loop that looks like this so I can acces the position with i
for (int i = 0; i < Text1.TextLength; i++) {
//I can use things here like Text1.Text[i]...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与您实现上标的方式相同。
使用 SelectionCharOffset 属性(连同
SelectionStart
和SelectionLength
一次选择一个字符)并查看其是否为正数(因为正数表示上标,负数表示下标)。The same way you achieved superscript.
Use the SelectionCharOffset property (along with
SelectionStart
andSelectionLength
to select one character at a time) and see if its a positive number (since positive represents superscript and negative represents subscript).