I'm trying to merge several files into one document, in order to produce a dynamic report.
I can load data into a RadRichTextBox, however after using the code in another forum post, to load another file into a RadDocument object, and then use the Selection.SelectAll method to insert a fragment into the RichTextBox.
The ImportRTF function is:- (and works fine, as it loads a file into the RichTextBox perfectly)
However, when calling the SelectAll function on a RadDocument (which isn't a RichTextBox contents) , it doesn't return anything (IsEmpty is True).
Modifying the code to look at the existing RichTextBox contents, and the selection code works fine.
Please help, as it's crucial I can combine document files together.
Thanks
I can load data into a RadRichTextBox, however after using the code in another forum post, to load another file into a RadDocument object, and then use the Selection.SelectAll method to insert a fragment into the RichTextBox.
private
void
button2_Click(
object
sender, RoutedEventArgs e)
{
try
{
RadDocument document2 =
new
RadDocument();
document2 = ImportRTF();
document2.Selection.SelectAll();
this
.radRichTextBox1.Document.InsertFragment(document2.Selection.CopySelectedDocumentElements());
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
The ImportRTF function is:- (and works fine, as it loads a file into the RichTextBox perfectly)
public
RadDocument ImportRTF()
{
try
{
RadDocument document =
null
;
IDocumentFormatProvider provider =
new
RtfFormatProvider();
OpenFileDialog openDialog =
new
OpenFileDialog();
openDialog.Filter =
"Documents|*.rtf"
;
openDialog.Multiselect =
false
;
bool
? dialogResult = openDialog.ShowDialog();
if
(dialogResult ==
true
)
{
//MessageBox.Show(openDialog.File.FullName);
using
(FileStream stream = openDialog.File.OpenRead())
{
document = provider.Import(stream);
}
}
return
document;
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
return
null
;
}
}
However, when calling the SelectAll function on a RadDocument (which isn't a RichTextBox contents) , it doesn't return anything (IsEmpty is True).
Modifying the code to look at the existing RichTextBox contents, and the selection code works fine.
Please help, as it's crucial I can combine document files together.
Thanks