CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2009
    Posts
    10

    Question MultiLine Textboxes??

    Hi!
    I am programming in C# for a class. I am using visual studio 2008 with .NET 3.5. I have a multiline textbox on a form but I can't get it to use newlines (\n). Is there some magic way to insert a new line into a textbox? Is there a better control to use? I want it to output like a console.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: MultiLine Textboxes??

    One, newlines on Windows are not \n, they are \r\n. Two, I'm not sure what you mean by "I can't get it to use newlines". Can you be more specific?

  3. #3
    Join Date
    Dec 2009
    Posts
    10

    Re: MultiLine Textboxes??

    My code for the box looks like this

    Output.Text += "Starting New Run!!! \n";

    How ever. It ignores the newline. It should print

    Starting new run!
    Starting new run!
    Starting new run!

    instead it prints


    Starting new run!Starting new run!Starting new run!

  4. #4
    Join Date
    Dec 2009
    Posts
    10

    Re: MultiLine Textboxes??

    NEVERMIND! You solved it thanks!

  5. #5
    Join Date
    Nov 2009
    Location
    .net 3.5 csharp 2008 developer
    Posts
    36

    Re: MultiLine Textboxes??

    While \r\n will work, the preferred way would be using Enviroment.NewLine which makes sure it will be handled correctly in the future

  6. #6
    Join Date
    Jun 2008
    Posts
    2,477

    Re: MultiLine Textboxes??

    Quote Originally Posted by ixilom View Post
    While \r\n will work, the preferred way would be using Enviroment.NewLine which makes sure it will be handled correctly in the future
    Yes, absolutely correct. And it will also come in handy should you ever port your code to Mono.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured