Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-get-a-collection-of-lines-from-a-textbox.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.2 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Get a Collection of Lines from a TextBox 03/30/2017
lines [WPF], getting collection of
TextBox control [WPF], getting collection of lines
a12f529d-b926-47f6-92bf-cad5f17b532a

How to: Get a Collection of Lines from a TextBox

This example shows how to get a collection of lines of text from a xref:System.Windows.Controls.TextBox.

Example

The following example shows a simple method that takes a xref:System.Windows.Controls.TextBox as the argument, and returns a xref:System.Collections.Specialized.StringCollection containing the lines of text in the TextBox. The xref:System.Windows.Controls.TextBox.LineCount%2A property is used to determine how many lines are currently in the TextBox, and the xref:System.Windows.Controls.TextBox.GetLineText%2A method is then used to extract each line and add it to the collection of lines.

[!code-csharpTextBox_MiscCode#_TextBox_GetLines]

See also