How To Add A New Line in a C# or Visual Basic TextBox
Published 2 years, 9 months ago in C#If you're building a Windows Form Application, for example with C# or Visual Basic, then you may need to add a new line character, for example in a multiline TextBox. You do this using Enviroment.NewLine to insert the line break as follows:
-
textBox1.Text="First Line" + Environment.NewLine + "Second Line";
My preferred use is with the += operator in C#:
-
textBox1.Text = "Line One";
-
textBox1.Text += Environment.NewLine;
-
textBox1.Text += "Line Two";
This way, you can add extra lines of output to the TextBox as you require it.
References: Environment.NewLine on MSDN
If you have a low-traffic website, consider joining the Money4Banners advertising network. They will pay you £10 + £5 each month for displaying a small advert on three of your pages, regardless of traffic. American webmasters are welcome, and since £10 == $20, you make more!
9 Responses to “How To Add A New Line in a C# or Visual Basic TextBox”
Leave a Reply
You must log in to post a comment.
Search
Categories
- ASP (3)
- ASP Basics (3)
- Blogs (2)
- C# (1)
- Firefox (1)
- Flash (1)
- Google (6)
- Hacks (3)
- Java (1)
- PHP (12)
- Basics (8)
- Files (1)
- Image Handling (3)
- Puzzles (1)
- Ruby (1)
- Tips (10)
- Web Hosting (3)
- Web Hosting Articles (1)
- Web Hosting News (2)
- Windows (6)
- Wordpress (2)
Related Entries
- Reading a file's contents with PHP
- How to use PHP in pages with a .html extension (or any other)
- Output redirection to a file from the Windows Command Line
- Kill a Process from the Windows Command Line
- Write Text on to an existing PNG image using PHP
- List all processes with the Windows Command Line
- Generate a Month Calendar In PHP
- Add Notepad To Your "Send To" Menu
- The Difference Between require() and include()
- How to Access a Page in Google's Cache
Hey,
Thats a good one …
Excellent - just what I was looking for! Thanks
Fast and clean.
Many thanks!
Thx!! I really needed this! great
Thata was simple but hard to find
Thnxs , just what I need!
Really it is excellent.Bez i was thinking for more hours but easily i found this!
Yeahh. But not working un vb 6
easier even is just vbNewLine in Visual Basic
textBox1.Text=”First Line” vbNewLine “Second Line”