Groups | Blog | Home
all groups > c# > october 2003 >

c# : How to display multilines in textbox


Tom
10/8/2003 11:20:47 PM
Hi,

Here is the code:

this.textBox1.AcceptsReturn = true;
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars =
System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(552, 296);
this.textBox1.TabIndex = 0;
this.textBox1.Text = DateTime.Now + " hello ....." +
Environment.NewLine;
this.textBox1.TextChanged += new System.EventHandler
(this.textBox1_TextChanged);

private void timer1_Tick(object sender, System.EventArgs e)
{
this.textBox1.Text = DateTime.Now + " welcome ....." +
Environment.NewLine;
}

I want to display the text in the text box like the
following:

DateTime hello
DateTime welcome
DateTime welcome
DateTime welcome
DateTime welcome
DateTime welcome
DateTime welcome
DateTime welcome
DateTime welcome
.....

Environment.NewLine seems does not work. How can I do
that?

Thanks







Tom Pair
10/9/2003 3:47:19 AM
DateTime.Now + " welcome... \r\n";

It does not work.

There is only a single line displaying in the multiline textbox. The
single line keeps on updating with the timer.





*** Sent via Developersdex http://www.developersdex.com ***
Tom Pair
10/9/2003 6:39:09 AM
Thank you for your kind help. It works now.



*** Sent via Developersdex http://www.developersdex.com ***
Stefan
10/9/2003 8:30:23 AM
try to use "\r\n" for a new line
DatTime.Now + " hello... \r\n" + ...
[quoted text, click to view]

Gareth Parris
10/9/2003 12:20:58 PM
Surely you meant to do this....

private void timer1_Tick(object sender, System.EventArgs e)
{
this.textBox1.Text += DateTime.Now + " welcome ....." +
Environment.NewLine;
}




[quoted text, click to view]

Daniel Bass
10/9/2003 12:58:22 PM
Environment.NewLine is only a constant that equals "\r\n"

if "\r\n" doesn't work, nor will the constant.

Dan.

[quoted text, click to view]
Surely you meant to do this....

private void timer1_Tick(object sender, System.EventArgs e)
{
this.textBox1.Text += DateTime.Now + " welcome ....." +
Environment.NewLine;
}




[quoted text, click to view]


Daniel Bass
10/9/2003 2:05:02 PM
Gareth's right, you're not appending the text.

[quoted text, click to view]
Surely you meant to do this....

private void timer1_Tick(object sender, System.EventArgs e)
{
this.textBox1.Text += DateTime.Now + " welcome ....." +
Environment.NewLine;
}




[quoted text, click to view]


AddThis Social Bookmark Button