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

TableRow createDeepCopy() error

2 Answers 15 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
zou
Top achievements
Rank 1
zou asked on 17 Jul 2018, 01:51 AM

I have a xamlDocument,that contains tables, in one table,i need to copy some rows and then add to the table!

But, when i use:

   TableRow newRow = copyRow.CreateDeepCopy() as TableRow;
        tableAndRow.Item1.Rows.AddAfter(row, newRow);

2 Answers, 1 is accepted

Sort by
0
zou
Top achievements
Rank 1
answered on 17 Jul 2018, 02:03 AM

sorry for the problem above!

As supplementary:

tableAndRow is a tuple of table,and the row need to copy,

 tableAndRow.Item1 is the table ,

 copyRow is one row of the table, contains FieldRangeStart,MergeField,FieldRangeEnd,ReadOnlyRangeStart, ReadOnlyRangeEnd,

 

after copy the rows and add to the table, save, error occured:"system.NullReferenceException.Object reference not set to an instance of an object":

some codes:

//findPosition
Tuple<Table, TableRow> tableAndRow = FindTableAndRowInDocument(xamlDocument, attachment.KeyWord);
TableRow row = tableAndRow.Item2;
for (int i = 0; i < attachment.IndexStart * attachment.CopyRowCount - 1; i++)
row = (TableRow)(row.NextSibling);
//移动到需要添加信息的位置
xamlDocument.CaretPosition.MoveToEndOfDocumentElement(row);

TableRow copyRow = tableAndRow.Item2;
for (int i = 0; i < attachment.CopyRowCount; i++)
{
//在指定位置添加行
TableRow newRow = copyRow.CreateDeepCopy() as TableRow;
tableAndRow.Item1.Rows.AddAfter(row, newRow);

row = newRow;
copyRow = (TableRow)copyRow.NextSibling;
}

 

 

//write RadDocument
XamlFormatProvider provider = new XamlFormatProvider();
String savePath = Path.Combine(App.WorkingFolder, basePath, sectionID, "s000000");
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
savePath = Path.Combine(savePath, "section.xaml");
using (FileStream output = new FileStream(savePath, FileMode.OpenOrCreate))
{
RadDocument document = xamlDocument;
provider.Export(document, output);  //the error occured here
}

how to solve this problem?

 

0
Tanya
Telerik team
answered on 19 Jul 2018, 03:09 PM
Hello Zou,

Copying and pasting whole table rows is currently not supported. We have logged a task to expose a similar functionality and you can vote for its implementation as well as track its status using the related public item. I am afraid that there is not much I can suggest in order to achieve the desired behavior. In case adding the rows on the last position is an option for you, this can be achieved by copying the rows and pasting them after the table. In this case, the rows will be pasted into different tables, though.

Hope this information is helpful.

Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
zou
Top achievements
Rank 1
Answers by
zou
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or