Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to: Load a RichTextBox control using stream (non-filestream)

Posted on 2004-08-17
3
Medium Priority
?
653 Views
Last Modified: 2010-05-18
Hello,

I have a RichTextBox control on a VB .NET form.  I have successfully translated an XML document into RTF and would like to load it into the RichTextBox control without writing the results of the XSLT translation to a file...  Thanks in advance for your help.  Here's what I have so far:

  Private Sub LoadRichTextBox()
      'vars
      Dim _XmlDoc As New XmlDocument()
      Dim _XslDoc As New System.Xml.Xsl.XslTransform()
      Dim _XmlTextWriter As XmlTextWriter
      '**Dim _MemoryStream As New MemoryStream()

       _XmlDoc.Load("Source.xml")

       _XslDoc.Load("xml2rtf.xslt")

       'transform to RTF and save it to file.
       _XmlTextWriter = New XmlTextWriter("Temp.rtf", System.Text.Encoding.Default)
       _XslDoc.Transform(_XmlDoc, Nothing, _XmlTextWriter)
       '** _XslDoc.Transform(_XmlDoc, Nothing, _MemoryStream)

       '** i would like to use a stream rather than a file here!
       txtDsr.LoadFile("Temp.rtf", RichTextBoxStreamType.RichText)
       '** txtDsr.LoadFile(_MemoryStream, RichTextBoxStreamType.RichText)

        _XmlTextWriter.Close()
        '** _MemoryStream.Close()

   End Sub
0
Comment
Question by:bilpar
  • 2
3 Comments
 

Author Comment

by:bilpar
ID: 11827036
Hello,

I have made some progress...  Uncommenting the _MemoryStream lines of code and adding the following line just before the txtDsr.LoadFile:

_MemoryStream.Seek(0, SeekOrigin.Begin)

yields:

"Invalid file format"


By the way, I meant to rename txtDsr to RichTextBox1 in the example above.
0
 

Author Comment

by:bilpar
ID: 11827066
Hello again,

I did manage to get this working.  So I would like to change the question.  I have coded several functions using streams but i do not fully understand how these darn things work.  So, each time I hunt and guess... until something good happens.  I think it best that I fully understand how they work.

The question is now:  "Please point me to a good tutorial on working with Streams"

Thanks,

Bil
0
 
LVL 3

Accepted Solution

by:
Scoobyed earned 2000 total points
ID: 11838642
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question