Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetFirstCharIndexFromLine Method

TextBoxBase.GetFirstCharIndexFromLine Method

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

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

public int GetFirstCharIndexFromLine(
	int lineNumber
)

Parameters

lineNumber
Type: System.Int32

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

Return Value

Type: System.Int32
The zero-based index of the first character in the specified line.

ExceptionCondition
ArgumentOutOfRangeException

The value of the lineNumber parameter is less than zero.

Line numbering in the text box starts at zero. If the lineNumber parameter is greater than the last line in the text box, 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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft