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);
7 Answers, 1 is accepted
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
{
try
{
XamlFormatProvider provider = new XamlFormatProvider();
return provider.Import(content);
}
catch (Exception ex)
{
throw ex;
}
}
Such input cannot be imported with the XamlFormatProvider. You can use the HtmlFormatProvider instead, or the RichTextEditor to save the documents first.
Please let me know if there is something else I can help you with.
Dimitar
Telerik by Progress
Hi,
Thanks for your reply.
I used HtmlFormatProvider and my output was this Telerik.WinForms.Documents.Model.RadDocument
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.
Dimitar
Telerik by Progress
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.
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