By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,842 Members | 2,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,842 IT Pros & Developers. It's quick & easy.

How to display multilines in textbox

P: n/a
Tom
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


Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
try to use "\r\n" for a new line
DatTime.Now + " hello... \r\n" + ...
"Tom" <ke*****@yahoo.com> wrote in message
news:08****************************@phx.gbl...
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



Nov 15 '05 #2

P: n/a
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 ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

P: n/a
Surely you meant to do this....

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


"Tom Pair" <ke*****@yahoo.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
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 ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #4

P: n/a
Environment.NewLine is only a constant that equals "\r\n"

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

Dan.

"Gareth Parris" <gc******@hotmail.comm> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
Surely you meant to do this....

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


"Tom Pair" <ke*****@yahoo.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
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 ***
Don't just participate in USENET...get rewarded for it!


Nov 15 '05 #5

P: n/a
Gareth's right, you're not appending the text.

"Gareth Parris" <gc******@hotmail.comm> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
Surely you meant to do this....

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


"Tom Pair" <ke*****@yahoo.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
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 ***
Don't just participate in USENET...get rewarded for it!


Nov 15 '05 #6

P: n/a
Thank you for your kind help. It works now.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.