Click here to Skip to main content
14,774,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
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

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

as

textBox2.Text += textBox1.Text + Environment.NewLine;
   
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 = "";
        }
   

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900