Solved

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

Posted on 2004-08-17
3
606 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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