Profile Picture

NRichTextView having issues saving RTF string

Posted By Tom Galczynski 5 Years Ago
Author
Message
Tom Galczynski
Problem Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 29, Visits: 87
Hello. I'm using the NRichTextView control to construct a 3x2 table with string data in each cell.
The problem is when I extract the RTF string from the widget, I save it to a column in a SQL table,
and when I subsequently push that string back to the control when opening my form, it only shows the
first column of the table. Here are the properties I amusing in my code to get and set the RTF string
in the NRichTextView:

  Public Property Rtf As System.String
   Get
    Dim currentFormat As RichTextEdit.DocumentFormats = Me._format

    Try

      Me.Format = DocumentFormats.Rtf

      Using ms As System.IO.MemoryStream = Me.Stream
       Return _encoding.GetString(ms.ToArray)
      End Using

    Finally

      Me.Format = currentFormat

    End Try
   End Get
   Set(value As System.String)
    Dim currentFormat As RichTextEdit.DocumentFormats = Me._format

    Try

      Me.Format = RichTextEdit.DocumentFormats.Rtf
      Using ms As New System.IO.MemoryStream(_encoding.GetBytes(value))
       Me.Stream = ms
      End Using

    Finally

      Me.Format = currentFormat

    End Try
   End Set
  End Property

  Public Property Stream As System.IO.MemoryStream
   Get

    Dim richTextView As Nevron.Nov.Text.NRichTextView = Me._currentView

    If richTextView IsNot Nothing Then
      Dim currentLayout As Nevron.Nov.Text.ENTextLayout = richTextView.Content.Layout
      Try
       richTextView.Content.Layout = Me._currentLayout
       Dim MS As New System.IO.MemoryStream
       richTextView.SaveToStream(MS, Me.DocumentFormat)
       Return MS
      Finally
       richTextView.Content.Layout = currentLayout
      End Try
    End If

    Return Nothing
   End Get
   Set(value As System.IO.MemoryStream)

    If value IsNot Nothing Then

      Dim richTextView As Nevron.Nov.Text.NRichTextView = Me._currentView

      If richTextView IsNot Nothing Then
       richTextView.Content.Sections.Clear()
       richTextView.LoadFromStream(value, Me.DocumentFormat)
       Me._currentLayout = richTextView.Content.Layout

       If Me._navigation = NavigationView.None Then
        'When displaying the plain control, display the contents in web view so scrollbars, etc. work properly.
        richTextView.Content.Layout = Nevron.Nov.Text.ENTextLayout.Web
       End If

      End If

    End If

   End Set
  End Property

It doesn't matter if I construct the table programatically or in the GUI the result is the same. Is there
anything I can do to prevent this from happening? The encoding is UTF8. Any hints would be appreciated.

Thanks!

Tom G.
 




Similar Topics


Reading This Topic