TextBoxBase.Lines プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

[LocalizableAttribute(true)] public: property array<String^>^ Lines { array<String^>^ get (); void set (array<String^>^ value); }
/** @property */ public String[] get_Lines () /** @property */ public void set_Lines (String[] value)
テキスト ボックス コントロールのテキストを格納する文字列の配列。

配列内の各要素は、テキスト ボックス コントロールのテキスト行になります。テキスト ボックス コントロールの Multiline プロパティが true に設定されているときに、テキストに改行文字が表示されると、改行文字の後ろに続くテキストが配列内の新しい要素に追加されて、別の行に表示されます。
![]() |
---|
既定では、返される行のコレクションは、TextBox に含まれる行の読み取り専用のコピーです。書き込み可能な行のコレクションを取得するには、textBox1.Lines = new string[] { "abcd" }; などのコードを使用します。 |

派生クラス TextBox を使用して、複数行テキスト ボックス コントロールからすべての文字列を抽出し、それらの文字列を Debug.WriteLine メソッドを使用して表示するコード例を次に示します。この例では、textBox1 という名前の TextBox コントロールが作成されており、そのコントロールにテキスト行が入力されている必要があります。
Public Sub ViewMyTextBoxContents() Dim counter as Integer 'Create a string array and store the contents of the Lines property. Dim tempArray() as String tempArray = textBox1.Lines 'Loop through the array and send the contents of the array to debug window. For counter = 0 to tempArray.GetUpperBound(0) System.Diagnostics.Debug.WriteLine( tempArray(counter) ) Next End Sub
public void ViewMyTextBoxContents() { // Create a string array and store the contents of the Lines property. string[] tempArray = new string [textBox1.Lines.Length]; tempArray = textBox1.Lines; // Loop through the array and send the contents of the array to debug window. for(int counter=0; counter < tempArray.Length;counter++) { System.Diagnostics.Debug.WriteLine(tempArray[counter]); } }
public: void ViewMyTextBoxContents() { // Create a string array and store the contents of the Lines property. array<String^>^ tempArray = gcnew array<String^>( textBox1->Lines->Length ); tempArray = textBox1->Lines; // Loop through the array and send the contents of the array to debug window. for ( int counter = 0; counter < tempArray->Length; counter++ ) { System::Diagnostics::Debug::WriteLine( tempArray[ counter ] ); } }
public void ViewMyTextBoxContents() { // Create a string array and store the contents of the Lines property. String tempArray[] = new String[textBox1.get_Lines().length]; tempArray = textBox1.get_Lines(); // Loop through the array and send the contents of the array to // debug window. for (int counter = 0; counter <= tempArray.length; counter++) { System.Diagnostics.Debug.WriteLine(tempArray.get_Item(counter)); } } //ViewMyTextBoxContents

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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からTextBoxBase.Lines プロパティを検索する場合は、下記のリンクをクリックしてください。

- TextBoxBase.Lines プロパティのページへのリンク