Hi,
I am trying to remove table from blocks so above error message comes and table not able to remove.
my code
how to resolve this error
I am trying to remove table from blocks so above error message comes and table not able to remove.
my code
Telerik.Windows.Documents.Model.Span spanbox = editor.Document.CaretPosition.GetCurrentSpanBox().AssociatedSpan;
StyleDefinition expansionstyle =
new
StyleDefinition();
expansionstyle.SpanProperties =
new
SpanProperties() { FontWeight = FontWeights.SemiBold, ForeColor = Colors.Brown };
if
(spanbox.FontWeight == FontWeights.SemiBold && spanbox.ForeColor == Colors.Brown)
{
Telerik.Windows.Documents.Model.Section currsect = editor.Document.CaretPosition.GetCurrentSectionBox().AssociatedSection;
bool
check = editor.Document.CaretPosition.MoveToNextInline();
var documentelement = editor.Document.CaretPosition.GetCurrentTableBox();
if
(documentelement!=
null
&& documentelement.GetType() ==
typeof
(TableLayoutBox))
{
spanbox.Tag = Guid.NewGuid().ToString();
//var tableStyle = editor.Document.StyleRepository["TableGrid"] as StyleDefinition;
Telerik.Windows.Documents.Model.Table tbl = documentelement.AssociatedTable;
if
(tbl !=
null
)
{
TableHelper Thelp =
new
TableHelper();
Thelp.TableReferenceId = spanbox.Tag;
foreach
(Telerik.Windows.Documents.Model.TableRow c
in
tbl.Rows)
{
TableRowHelper rowhelper =
new
TableRowHelper();
foreach
(Telerik.Windows.Documents.Model.TableCell cell
in
c.Cells)
{
TableCellHelper cellhepl =
new
TableCellHelper();
foreach
(DocumentElement block
in
cell.Blocks)
{
DocumentElementCollection docelement =
new
DocumentElementCollection(block);
foreach
(var item
in
block.Children)
{
docelement.Add(item);
}
cellhepl.DocumentElementCollection.Add(docelement);
}
rowhelper.TableCellCollection.Add(cellhepl);
}
Thelp.TableRowHelperCollection.Add(rowhelper);
}
TableHelpCollection.Add(Thelp);
ExpandedColl.Add(spanbox.Tag, tbl);
//stylecoll.Add(spanbox.Tag, tableStyle);
}
styles.Add(spanbox.Tag, documentelement.AssociatedTable.Style);
currsect.Blocks.Remove(tbl);
//editor.Document.StyleRepository.Add(tableStyle);
}
how to resolve this error