Load multiple documents to a radDocument[] array

8 posts, 0 answers
  1. Sandhya
    Sandhya avatar
    4 posts
    Member since:
    Jul 2016

    Posted 25 Jul Link to this post

    Hi,

    I am trying to load documents to a radDocument[] array. When executing below code i  get "exception has been thrown by the target of an invocation c#" error.  Kindly Help.

    Here is my code:

    RadDocument[] Rd_Ary = new RadDocument[2];
                
    Rd_Ary[0]=ImportHtml(Convert.ToString("<P>String1</P>"));
    Rd_Ary[1] = ImportHtml(Convert.ToString("<P>String2</P>"));

    Alternative code:

     Rd_Ary.SetValue(ImportHtml(Convert.ToString("<P>String1</P>")), 0);
     Rd_Ary.SetValue(ImportHtml(Convert.ToString("<P>String2</P>")), 1);

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 25 Jul Link to this post

    Hi Sandhya,
     
    Thank you for writing.

    I have tested this with the following code and there is no exception on my side: 
    void button_Click(object sender, EventArgs e)
    {
        RadDocument[] Rd_Ary = new RadDocument[2];
     
        HtmlFormatProvider provider = new HtmlFormatProvider();
        
        Rd_Ary[0] = provider.Import(Convert.ToString("<P>String1</P>"));
        Rd_Ary[1] = provider.Import(Convert.ToString("<P>String2</P>"));
    }

    What is the code inside your ImportHtml method? Maybe something is different. 

    I am looking forward to your reply.

    Regards,
    Dimitar
    Telerik by Progress
    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sandhya
    Sandhya avatar
    4 posts
    Member since:
    Jul 2016

    Posted 25 Jul in reply to Dimitar Link to this post

    public RadDocument ImportHtml(string content)
            {
                try
                {

                    XamlFormatProvider provider = new XamlFormatProvider();
                    return provider.Import(content);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 25 Jul Link to this post

    Hello Sandhya,

    Such input cannot be imported with the XamlFormatProvider. You can use the HtmlFormatProvider instead, or the RichTextEditor to save the xaml documents first. 

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik by Progress
    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.
  6. Sandhya
    Sandhya avatar
    4 posts
    Member since:
    Jul 2016

    Posted 25 Jul in reply to Dimitar Link to this post

    Hi,

    Thanks for your reply.

    I used HtmlFormatProvider and my output was this Telerik.WinForms.Documents.Model.RadDocument

  7. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 26 Jul Link to this post

    Hello Sandhya,

    This is the expected result. Then you can show the document in RadRichTextEditor like this:
    void button_Click(object sender, EventArgs e)
    {
        RadDocument[] Rd_Ary = new RadDocument[2];
     
        var provider = new HtmlFormatProvider();
        string s = provider.Export(radRichTextEditor1.Document);
     
        Rd_Ary[0] = provider.Import(Convert.ToString("<P>String1</P>"));
        Rd_Ary[1] = provider.Import(Convert.ToString("<P>String2</P>"));
     
        radRichTextEditor1.Document = Rd_Ary[1];
    }

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik by Progress
    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.
  8. Sandhya
    Sandhya avatar
    4 posts
    Member since:
    Jul 2016

    Posted 27 Jul in reply to Dimitar Link to this post

    Hi,

    Thanks for your reply.My problem is solved.

    I have one more doubt.

    I want to set header and footer programmatically in a richtextEditor when loading a template.How can i achieve it.

  9. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 27 Jul Link to this post

    Hello Sandhya,

    The following section shows how you can create a header and add it to a document: Headers and Footers.
     
    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik by Progress
    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