Import rtf into radrichtextbox

8 posts, 0 answers
  1. Nallan Krishnan
    Nallan  Krishnan avatar
    10 posts
    Member since:
    Jun 2010

    Posted 10 Jul 2012 Link to this post

    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.
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Jul 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nallan Krishnan
    Nallan  Krishnan avatar
    10 posts
    Member since:
    Jun 2010

    Posted 16 Jul 2012 Link to this post

    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.
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 18 Jul 2012 Link to this post

    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 >>
  6. Mike
    Mike avatar
    26 posts
    Member since:
    Dec 2006

    Posted 20 Aug 2012 Link to this post

    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();
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 23 Aug 2012 Link to this post

    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 >>
  8. vahid
    vahid avatar
    7 posts
    Member since:
    May 2016

    Posted 02 Jun Link to this post

    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

  9. Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 02 Jun Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready