0

Hi all,
I am trying to write a string to a multiline textbox but apearently my code doesnt do as i want...
This is the code i am using :

textBox9>Lines[0]="Succes";

But when the code executes nothing happens in the textbox, everything just stays thesame :S
Am i doing something wrong?, if i am pleas point me out and help me fix this error.
Thanks in advanced.

3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by Martje
0

The whole function is like this

private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e)
		 {
			textBox9->Lines[0]="Succes";
		 }
0

textBox1->Lines = gcnew array<String^> {"Success"}; is the command that you need. Buried in the MSDN entry for Lines I found the following:

Note:

By default, the collection of lines is a [B]read-only[/B] (my emphasis added) copy of the lines in the TextBox. To get a writable collection of lines, use code similar to the following: textBox1.Lines = new string[] { "abcd" };
0

textBox1->Lines = gcnew array<String^> {"Success"}; is the command that you need. Buried in the MSDN entry for Lines I found the following:

Note:

By default, the collection of lines is a [B]read-only[/B] (my emphasis added) copy of the lines in the TextBox. To get a writable collection of lines, use code similar to the following: textBox1.Lines = new string[] { "abcd" };

i tried that and it worked but how do i change a specific array line?
for example line 3,etc
and can i get the msdn link :) ?
Thanks in advanced.

0

Sure here's the link.

To get a specific member you just need to rebuild the string array each time. Will get it in the next post hang on.

Edited by jonsca: C# hat on

0

So to get the fourth and sixth (3rd and 5th in the array) positions you'd need something like textBox1->Lines = gcnew array<String^> {"","","","fourth","","sixth"}; Apologies for the edits on the last one.

Edited by jonsca: n/a

0

Thank you very much

Apologies for the edits on the last one.

No problem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.