TextBoxBase.GetFirstCharIndexFromLine(Int32) 方法

定义

检索给定行第一个字符的索引。Retrieves the index of the first character of a given line.

public:
 int GetFirstCharIndexFromLine(int lineNumber);
public int GetFirstCharIndexFromLine (int lineNumber);
member this.GetFirstCharIndexFromLine : int -> int
Public Function GetFirstCharIndexFromLine (lineNumber As Integer) As Integer

参数

lineNumber
Int32

要获取其第一个字符的索引的行。The line for which to get the index of its first character.

返回

指定行中第一个字符的从零开始的索引。The zero-based index of the first character in the specified line.

异常

lineNumber 参数的值小于零。The value of the lineNumber parameter is less than zero.

注解

文本框中的行号从零开始。Line numbering in the text box starts at zero. 如果 lineNumber 参数大于文本框中的最后一行,则 GetFirstCharIndexFromLine 返回-1。If the lineNumber parameter is greater than the last line in the text box, GetFirstCharIndexFromLine returns -1.

GetFirstCharIndexFromLine 返回物理行的第一个字符索引。GetFirstCharIndexFromLine returns the first character index of a physical line. 物理行是显示的行,而不是所分配的行。The physical line is the displayed line, not the assigned line. 由于换行,显示的行数可以大于分配的行数。The number of displayed lines can be greater than the number of assigned lines due to word wrap. 例如,如果将两个长行分配给 RichTextBox 控件并将 MultilineWordWrap 设置为 true,则两个长时间分配的行将导致四个物理(或显示的行)。For example, if you assign two long lines to a RichTextBox control and set Multiline and WordWrap to true, the two long assigned lines result in four physical (or displayed lines).

适用于

另请参阅