Zac*_*son 6 .net c# textbox winforms
如果我请textBox.GetLineFromCharIndex(int)在TextBox带WordWrap = true,它作为用户根据换行符看到它(包装线算作多行),而不是行返回的行索引.
Line one extends to // <- word wrapped here. // <- logical line 1, GetLineFromCharIndex returns line 2 This is line two. // <- logical line 2, GetLineFromCharIndex returns line 3
有没有人知道从字符索引而不是显示的行找到逻辑行的解决方案?
查找整个文本中直到字符索引处换行符出现的次数。
也许首先将文本框文本的子字符串获取到您的字符索引。对换行符使用 Split,并计算结果。
或者,循环解决方案将使用 Index 函数并计算在 char 索引之前找到的换行符数量。