Export (0) Print
Expand All

TextBoxBase.GetLineFromCharIndex Method

Retrieves the line number from the specified character position within the text of the control.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public virtual int GetLineFromCharIndex (
	int index
)
public int GetLineFromCharIndex (
	int index
)
public function GetLineFromCharIndex (
	index : int
) : int
Not applicable.

Parameters

index

The character index position to search.

Return Value

The zero-based line number in which the character index is located.

This method enables you to determine the line number based on the character index specified in the index parameter of the method. The first line of text in the control returns the value zero. The GetLineFromCharIndex method returns the physical line number where the indexed character is located within the control. For example, if a portion of the first logical line of text in the control wraps to the next line, the GetLineFromCharIndex method returns 1 if the character at the specified character index has wrapped to the second physical line. If WordWrap is set to false, no portion of the line wraps to the next, and the method returns 0 for the specified character index. You can use this method to determine which line a specific character index is located within. For example, after calling the Find method to search for text, you can obtain the character index to where the search results are found. You can call this method with the character index returned by the Find method to determine which line the word was found.

NoteNote:

If the character index specified in the index parameter is beyond the available number of lines contained within the control, the last line number is returned.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft