The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
TextBox.LineCount Property
.NET Framework 3.0
Gets the total number of lines in the TextBox.
Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
This example shows how to get a collection of lines of text from a TextBox.
The following example shows a simple method that takes a TextBox as the argument, and returns a StringCollection containing the lines of text in the TextBox. The LineCount property is used to determine how many lines are currently in the TextBox, and the GetLineText method is then used to extract each line and add it to the collection of lines.
StringCollection GetLinesCollectionFromTextBox(TextBox textBox)
{
StringCollection lines = new StringCollection();
// lineCount may be -1 if TextBox layout info is not up-to-date.
int lineCount = textBox.LineCount;
for (int line = 0; line < lineCount; line++)
// GetLineText takes a zero-based line index.
lines.Add(textBox.GetLineText(line));
return lines;
}
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.