Solved

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

Posted on 2004-08-17
3
595 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 500 total points
ID: 11838642
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now