Problem loading RTF file into windows richTextBox

Posted by Ted on Stack Overflow See other posts from Stack Overflow or by Ted
Published on 2010-05-01T14:23:56Z Indexed on 2010/05/01 14:27 UTC
Read the original article Hit count: 197

Filed under:
|
|

I am trying to load files into a windows (vs 2010) richTextBox but only the first line of the file is loading. I'm using:

        // Create an OpenFileDialog to request a file to open.
        OpenFileDialog openFile1 = new OpenFileDialog();

        // Initialize the OpenFileDialog to look for RTF files.
        openFile1.DefaultExt = "*.rtf";
        openFile1.Filter = "RTF Files|*.rtf";

        // Determine whether the user selected a file from the OpenFileDialog.
        if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
           openFile1.FileName.Length > 0)
        {
            // Load the contents of the file into the RichTextBox.
            rtbTest.LoadFile(openFile1.FileName);
        }

The test file I'm using is .cs file saved as an rtf file.

Any help appreciated please.

© Stack Overflow or respective owner

Related posts about richtextbox

Related posts about Windows