This documentation is archived and is not being maintained.

TextBoxBase.GetFirstCharIndexFromLine Method

Note: This method is new in the .NET Framework version 2.0.

Retrieves the index of the first character of a given line.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public int GetFirstCharIndexFromLine (
	int lineNumber
public int GetFirstCharIndexFromLine (
	int lineNumber
public function GetFirstCharIndexFromLine (
	lineNumber : int
) : int



The line for which to get the index of its first character.

Return Value

The zero-based character index in the specified line.

Exception typeCondition


The value of the lineNum parameter is less than zero.

If the lineNum parameter is negative, GetFirstCharIndexFromLine returns 0. If the lineNum parameter exceeds the number of lines in the control, GetFirstCharIndexFromLine returns -1.

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. 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).

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0