-
Textbox problem
I have a textbox that I wanted to use to list errors. However I can't dynamically add newline characters to make each error appear on a new line.
Here's the code I'm using to add the errors to the textbox
Code:
public string[] Errors
{
get
{
return errors;
}
set
{
errors = value;
errorLabel.Text = "";
foreach ( string error in value )
{
if ( errorLabel.Text.Length > 0 ) errorLabel.Text += "\n";
errorLabel.Text += string.Format( "● {0}", error );
}
errorLabel.Invalidate();
}
}
And here's what it looks like:
http://www.92hicks.com/Images/textbox.gif
AcceptReturn is set to 'true', but that only seems to affect User input rather than being able to programatically add newlines. Seems kinda odd.
Anyone have any ideas?
-
Re: Textbox problem
The windows escape sequence is "\r\n", mabye that's it?
-
Re: Textbox problem
Yep, that did it. Thanks LiquidShadows.
-
Re: Textbox problem
Just an example. Try using the textbox's lines property.
private void button1_Click(object sender, System.EventArgs e)
{
string lstrtest = "this is a test \nthis is line 2 \nand this is line 3";
textBox1.Lines = lstrtest.Split('\n');
}
-Satish
-
Re: Textbox problem
You must use Environtment.NewLine, don't use \n or \r...
Diego