PDA

Click to See Complete Forum and Search --> : *SOLVED* Adding text to a textbox programmatically


DJ_Catboy
Jan 16th, 2004, 09:11 AM
Hi,

Really stupid easy stupid question probably...

I want to add some data to a text box but using code. So I am doing...


textBox1.AppendText("AddressLine\n\r");


I have added this code to a button, repeated presses make the textbox's contents as follows:

AddressLineAddressLineAddressLine

And then when I count the number of lines it is showing as 3 - however the carriage returns are not working correctly!

Please can somebody help me!

Thanks,
DJ

Memnoch1207
Jan 16th, 2004, 10:30 AM
is the textboxes multiline property set to true?

Sgt-Peppa
Jan 16th, 2004, 10:36 AM
Make sure you added System.Text.RegularExpressions;,
set your textbox to multiline = true (like Memnoch1207 said) and change the order of the Expression. Do \r\n instead of \n\r.

HTH,

Stephan

Memnoch1207
Jan 16th, 2004, 10:41 AM
you can do it this way

textBox1.Text = textCheck1.Text + "Check" + System.Environment.NewLine;

Or

textBox1.AppendText("Check\r\n");

hellswraith
Jan 16th, 2004, 11:58 AM
textBox1.Text += "Check" + System.Environment.NewLine;

DJ_Catboy
Jan 19th, 2004, 02:56 AM
Thank you all for your help!

DJ