Click here to Skip to main content
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 20: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)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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