Jump to content

Windows Forms: Rich Text Box problems!

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Scirocco

Scirocco

    Newbie

  • Members
  • Pip
  • 5 posts
Hello again,

So I am giving my program a UI (windows forms), and part of the UI outputs the contents of a .txt file for the user to read.


foreach (Error errorFind in errorList)

            {                

                rtbFile.AppendText("Record #: " + errorFind.Number.ToString());                

                rtbFile.AppendText("Date: "+ errorFind.Date);

                rtbFile.AppendText("Time: " + errorFind.Time);              

                rtbFile.AppendText("Priority: " + errorFind.Priority.ToString());                

                rtbFile.AppendText("Description: " + errorFind.Description);

            }


The output works great, but since this is my first time outputting text to anything other than the Console, i assume that it hits enter each time. It doesn't :cursing:

As you can guess, it just outputs it in one line, only wrapping because it reaches the edge of my box. How can i get the program to create a new line (IE: hit enter). MSDN doesnt seem to be helping me with this...

Thanks! :)

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
You have to append Environment.NewLine manually to the end of a line.

Example:

rtbFile.AppendText("Record #: " + errorFind.Number.ToString() + Environment.NewLine);


Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
Scirocco

Scirocco

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks! That's all i needed to know :D




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users