This is a migrated thread and some comments may be shown as answers.

Export rtf to string

5 Answers 120 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 27 Mar 2016, 12:35 PM

Hello,

probably this will be a really simple and stupid question but nevertheless, I am stuck.

 

This is what I tried to do: We store rtf in a database and are planning to use Telerik controls in the future (there is a lot of impressive software inside).

Importing the rtf-text to RichTextEditor is quite easy. I simply put the content of the database field into a string variable and import it into RichtextEditore with this code:

Private Sub ImportRtf()
        Dim provider As New RtfFormatProvider()
        content = CStr(DataGridView.CurrentRow.Cells(xx).Value)
        Me.RadRichTextEditor1.Document = provider.Import(content)
    End Sub

This works perfectly.

After editing the text in RichTextEditor I need to export the new text as rtf to a string to store it in the database. I looked over the documentation and found this:

Public Function ExportToRtf(ByVal document As RadDocument) As String
        Dim provider As New RtfFormatProvider()
        Return provider.Export(document)
End Function

I tried to assign the function's return value to an another string variable:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim content1 As String = ExportToRtf()
        MsgBox(content1)
End Sub

VisualStudio puts a wiggled blue line under ExportToRtf() and demanded a missing argument for the functions's parameter "document".

Please tell me where my fault is.

Thanks in advance.

P. Arnold

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Mar 2016, 08:01 AM
Hello Peter,

Thank you for writing.

The provided ExportToRtf method has one parameter of type RadDocument. However, you call the method without passing any parameters. It is necessary to pass the RadRichTextEditor.Document in order to export its content. Additional information regarding the export functionality is available here: http://docs.telerik.com/devtools/winforms/richtexteditor/import/export

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Peter
Top achievements
Rank 1
answered on 28 Mar 2016, 10:32 AM

Hello, Dess,

thank you for your answer.

It was quite clear that I have to pass a parameter to the method. Unfortunately, the documentation is not as helpful as your answer was.

Best Regards,

P. Arnold

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Mar 2016, 07:31 AM
Hello Peter,

Thank you for writing back. 

I am glad that the provided information was helpful. The referred help article demonstrates a method how to export the content of a RadDocument which can be used to export the content of any RadRichTextEditor. It is just necessary to call the method passing the RadRichTextEditor.Document as a parameter.

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Evelyn
Top achievements
Rank 1
answered on 31 Mar 2017, 08:50 PM
RadRichTextEditor Como obtener el texto con el formato de texto y guardarlo en una BD
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Apr 2017, 05:11 AM
Hello Evelyn, 

Thank you for writing.  

I would like to note that the official language for communication in our forum is English. Thus, the community would gladly help you with the problems you are experiencing. 

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
RichTextEditor
Asked by
Peter
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Peter
Top achievements
Rank 1
Evelyn
Top achievements
Rank 1
Share this question
or