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.

傳回

Int32

指定行中第一個字元的以零起始的索引。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 控制項,並將 Multiline 和設定 WordWraptrue ,則兩個長時間指派的行會產生四個實體 (或顯示) 的行。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).

適用於

另請參閱