TextBoxBase.Lines Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Beolvashatja vagy beállíthatja a szövegsorokat egy szövegdoboz vezérlőelemben.
public:
property cli::array <System::String ^> ^ Lines { cli::array <System::String ^> ^ get(); void set(cli::array <System::String ^> ^ value); };
public string[] Lines { get; set; }
member this.Lines : string[] with get, set
Public Property Lines As String()
Tulajdonság értéke
Sztringek tömbje, amelyek a szövegdoboz vezérlőelemben lévő szöveget tartalmazzák.
Példák
Az alábbi példakód TextBoxegy származtatott osztály használatával kinyeri a szöveg összes sztringét egy többsoros szövegdoboz-vezérlőből, és megjeleníti őket a Debug.WriteLine metódus használatával. Ehhez a példához létre kell hozni egy TextBox vezérlőt, el kell nevezni textBox1, és meg kell töltenie szövegsorokkal.
public:
void ViewMyTextBoxContents()
{
#if defined(DEBUG)
// 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 ] );
}
#endif
}
public void ViewMyTextBoxContents()
{
// Create a string array and store the contents of the Lines property.
string[] 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 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
Megjegyzések
A tömb minden eleme szövegsorsá válik a szövegdoboz vezérlőelemben. Ha a Multiline szövegdoboz vezérlőelem tulajdonsága be van állítva true , és megjelenik egy új vonal karakter a szövegben, az új vonal karaktert követő szöveg hozzáadódik a tömb új eleméhez, és egy külön sorban jelenik meg.
Note
Alapértelmezés szerint a sorok gyűjteménye a sorok írásvédett másolata.TextBox Írható sorok gyűjteményének lekéréséhez használja a következőhöz hasonló kódot: textBox1.Lines = new string[] { "abcd" };