Click here to Skip to main content
11,639,554 members (64,195 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WinForm
Hi,I want to break a line in window form..

In a button click event i am displaying a text in text area and in the next click the next text should be displayed in a new line..can any one help this???


private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text += textBox1.Text + "\n\n";
            textBox1.Text = "";
        }
Posted 20-Feb-13 19:22pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Rewrite your code
textBox2.Text += textBox1.Text + "\n\n";

as

textBox2.Text += textBox1.Text + Environment.NewLine;
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

By using Environment.newline property we can get this...

private void button1_Click(object sender, EventArgs e)
        {
            //textBox2.Text += textBox1.Text + "\n\n";
            textBox2.Text += textBox1.Text + Environment.NewLine;
            textBox1.Text = "";
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 330
1 Sergey Alexandrovich Kryukov 259
2 CPallini 177
3 himanshu agarwal 167
4 F-ES Sitecore 160
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,812
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,548


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100