计算由RichTextBox中显示的行用C# [英] Counting lines displayed by richtextbox in C#
问题描述
在我的项目,我想指望通过的richtextbox在C#中有设置为true自动换行属性显示的行。例如,在RichTextBox中,我写的文本,并且当文本到达的richtextbox的宽度,那么它会自动进入第二行。所以会发生什么是文本实际上包含一条线,但它显示在两行。所以,我想知道我怎么能指望这为两行,而不是吗?帮助将非常AP preciated。
In my project I want to count lines displayed by richtextbox in C# with word wrap property set true. For example, in richtextbox, I write a text, and when text reaches the width of the richtextbox, then it automatically goes to second line. So what happens is the text contains actually one line but it is displayed in two lines. So I want to know how can I count this as two lines instead of one? Help will be really appreciated.
推荐答案
您可以去<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.getlinefromcharindex.aspx"><$c$c>RichTextBox.GetLineFromCharIndex方法
检索从行号
在指定的字符位置
RichTextBox控件的文本。如果自动换行
设置为假
,该行的任何部分换到下一个,该方法的返回0指定的字符索引。
Retrieves the line number from the specified character position within the text of the RichTextBox control. If
WordWrap
is set tofalse
, no portion of the line wraps to the next, and the method returns 0 for the specified character index.
此外,检查出这个链接。
这篇关于计算由RichTextBox中显示的行用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!