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

Import rtf into radrichtextbox

7 Answers 348 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Nallan Krishnan
Top achievements
Rank 1
Nallan Krishnan asked on 10 Jul 2012, 10:50 AM
Hi,

How can we import rtf into RadRichTextbox. We got the following code.

public RadDocument ImportDocx()
{
    RadDocument document = null;
    IDocumentFormatProvider provider = new DocxFormatProvider();
    OpenFileDialog openDialog = new OpenFileDialog();
    openDialog.Filter = "Documents|*.docx";
    openDialog.Multiselect = false;
    DialogResult dialogResult = openDialog.ShowDialog();
    if (dialogResult == System.Windows.Forms.DialogResult.OK)
    {
        using (FileStream stream = new FileStream(openDialog.FileName, FileMode.Open))
        {
            document = provider.Import(stream);
        }
    }
    return document;
}

But, it is not working. It is crashing while it tries to create the stream.

Please help us on this.

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Jul 2012, 06:11 AM
Hi Nallan,

Thank you for writing.

The reason for the observed behavior is that you are using the wrong provider to import RTF format. More information regarding the provider can be found here: http://www.telerik.com/help/winforms/richtextbox-features-import-export-import-export.html.

I hope that the provided information addresses your question. Let me know if you need further assistance with this matter.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Nallan Krishnan
Top achievements
Rank 1
answered on 16 Jul 2012, 07:27 AM
Hi,

Thanks for the information.

We are already using Telerik Winforms Q3 2009 SP1. Now, We need some special controls like Spell Checker, RichTextbox with Formatting (Bold,Italic,Highlight). So, we are testing the latest control Telerik winforms 2012. But, it requires .NET 4.0. we are already using .NET 3.5. And, we don't want to switch over to .NET 4.0.

So, In that case, what is the control suit we can purchase from you which will support the required controls (SpellChecker, Formatted RadRichTextbox) with .NET 3.5.

Please guide us, so that we can purchase the same.
0
Stefan
Telerik team
answered on 18 Jul 2012, 02:35 PM
Hi,

Indeed, the RadControls for WinForms suite requires .NET4.0 for the mentioned components. However, I am pretty confident that our WPF suite offers the same components built for .NET 3.5. Please, open a support ticket for this product in order to get final confirmation. 

I hope this helps.

Regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Mike
Top achievements
Rank 1
answered on 20 Aug 2012, 07:20 PM
I have tried importing an rtf document in WinForms. I have triwed every combination of namespaces but I seem to always end up being stuck between the Telerik.WinContol and Telerik.Windows ... namespaces and can't seem to get the right combinations or references when trying to convert the docx import sample to rtf import in a winforms app.Even trying to use the sample the "DocxFormatProvider()" comes back as an Unknown Type. If I reference tyhe Telerik.Windows... namespace It recognizes the DocxFormatProvider but then I get can't convert between Telerik.Wincontrols and Telerik.Windows...

Any help would be greatly appreciated.
Thanks

Nevermind, I finally got it:
IDocumentFormatProvider provider = new Telerik.WinControls.RichTextBox.FileFormats.Rtf.RtfFormatProvider();
0
Stefan
Telerik team
answered on 23 Aug 2012, 08:41 AM
Hi Mike,

That is the correct namespace indeed. In future if you are wondering about some namespace, you can search for the desired class in the documentation. Here is the first result of the search for the desired provider: http://www.telerik.com/help/winforms/t_telerik_wincontrols_richtextbox_fileformats_openxml_docx_docxformatprovider.html.

I hope this helps.
 
Regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
vahid
Top achievements
Rank 1
answered on 02 Jun 2016, 07:27 AM

Hi

I am using RadRichEdit Text Editor,

I want to import a rtf string from SQL server table in my text editor with formatting.

  public void  SetDescription(string desc)
        {
            RtfFormatProvider provider = new RtfFormatProvider();
            RadDocument rd = provider.Import(desc);   

but the problem is when I want to assign the text editor Document  property,

it raise an error:

Cannot implicitly convert type 'Telerik.Windows.Documents.Model.RadDocument' to 'Telerik.WinForms.Documents.Model.RadDocument'

 

how can I fix that

0
Dimitar
Telerik team
answered on 02 Jun 2016, 01:15 PM
Hi Vahid,

Thank you for writing.

You should use the objects from the following namespaces:
Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider provider = new Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider();
Telerik.WinForms.Documents.Model.RadDocument rd = provider.Import(desc);

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Nallan Krishnan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Nallan Krishnan
Top achievements
Rank 1
Mike
Top achievements
Rank 1
vahid
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or