I have a Xamrichtexteditor control, for which i bound a table, as below:
string error = ""; TableNode tn = xamRichTextEditor.Document.InsertTable(0, dt.Columns.Count, dt.Rows.Count, out error); tn.Settings = new TableSettings(); int cRow = 0, cCol = 0; tn.Rows[1].Cells[2].Settings = new TableCellSettings { FitText = true, Wrap = true, ColumnSpan = 4, };
tn.Rows[1].ChildNodes.RemoveAt(10); tn.Rows[1].ChildNodes.RemoveAt(10); tn.Rows[1].ChildNodes.RemoveAt(9);
tn.Rows[1].Cells[6].Settings = new TableCellSettings { FitText = true, Wrap = true, ColumnSpan = 3, };
tn.Rows[1].ChildNodes.RemoveAt(8); tn.Rows[1].ChildNodes.RemoveAt(7); if (error == null) { foreach (TableRowNode trn in tn.ChildNodes) { cCol = 0; foreach (TableCellNode tcn in trn.ChildNodes) { ParagraphNode pn = tcn.ChildNodes[0] as ParagraphNode; pn.SetText(dt.Rows[cRow][cCol].ToString()); cCol++; } cRow++; } }
And when this text is copied (either through ctrl+c or from the context menu) on to a notepad or excel sometimes the content is getting copied correctly , and sometime it is getting transposed after copy.
I cannot somehow upload an attachment, as this forum is giving me some error.
At least i can post the correct text copied, and the incorrect copied text.
*****************CORRECT*************************
Subject: NEW US CLO BWIC - $5mm 2.0 A - 1/8/2016 12:00:00 AM: 12:00:00 AM NEW US CLO BWIC - 1/8/2016 12:00:00 AM: 12:00:00 AM Body: CUSIP TICKER ORtg OFace TICKER ORtg OFace
************************************************
*****************IN-CORRECT*************************
Subject:NEW US CLO BWIC - $5mm 2.0 A - 1/8/2016 12:00:00 AM: 12:00:00 AM
Body:
CUSIPTICKERORtgOFace
********************************************************
When the below lines are commented in the above code , it seems to work fine.
tn.Rows[1].Cells[2].Settings = new TableCellSettings { FitText = true, Wrap = true, ColumnSpan = 4, };
tn.Rows[1].ChildNodes.RemoveAt(8); tn.Rows[1].ChildNodes.RemoveAt(7);
Can you help me with the correct usage of the ColumnSpan property of teh TableCellSettings class, which is causing the issue.
Hello Sowmya,
I would not expect the ColumnSpan property to create an issue in this case, but if you have a sample project I would like to see it. Our forum threads only allow an attachment to be < 1MB in size, which could be why you are getting the error. Please delete the bin and obj folders of the sample project you are trying to attach prior to trying to attach your sample.
Please let me know if you have any other questions or concerns on this matter.
I have issue in uploading my compressed project which is just 20 KB size as well. Its giving an Error.
However am inserting the code i used here :
***********MainWindow.xaml****************
<Window x:Class="XamRichTextEditorTblIssue.MainWindow" xmlns="">schemas.microsoft.com/.../presentation" xmlns:x="">schemas.microsoft.com/.../xaml" xmlns:d="">schemas.microsoft.com/.../2008" xmlns:mc="">schemas.openxmlformats.org/.../2006" xmlns:local="clr-namespace:XamRichTextEditorTblIssue" mc:Ignorable="d" xmlns:ig="">schemas.infragistics.com/xaml" Title="MainWindow" Height="350" Width="1050"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.Resources> <Style TargetType="{x:Type ig:XamContextMenu}"> <EventSetter Event="Loaded" Handler="XamContextMenu_Loaded" /> </Style> </Grid.Resources> <StackPanel Margin ="10" Grid.Row="0" Orientation="Horizontal"> <Button Name="TextForXamRichTextEditor" Margin="3" Content="Text For XamRichTextEditor" HorizontalAlignment="Left" Background="LightBlue" Click="TextForXamRichTextEditor_Click"/> <Button Name="TextForXamRichTextEditorWithColSpan" Margin="3" Content="Text For XamRichTextEditor WithColSpan" HorizontalAlignment="Left" Background="LightBlue" Click="TextForXamRichTextEditorWithColSpan_Click"/> </StackPanel> <ig:XamRichTextEditor Margin="5" Grid.Row="1" x:Name="xamrichtxtEditor"> <ig:XamRichTextEditor.ClipboardSerializationProviders> <ig:WordSerializationProvider/> <ig:RtfSerializationProvider/> <ig:HtmlSerializationProvider/> </ig:XamRichTextEditor.ClipboardSerializationProviders> </ig:XamRichTextEditor> </Grid></Window>
**********MainWindow.xaml****************
*********************************MainWindow.xaml.cs********************************
using System;using System.Collections.Generic;using System.Windows;using Infragistics.Controls.Menus;using Infragistics.Documents.RichText;
namespace XamRichTextEditorTblIssue{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); }
private void ConstructHTMLTableForRichTextEditor() { try { string error = ""; xamrichtxtEditor.Document.RootNode.Body.ChildNodes.Clear(); TableNode tn = xamrichtxtEditor.Document.InsertTable(0, 7, 5, out error); tn.Settings = new TableSettings(); int cRow = 0, cCol = 0;
if (error == null) { foreach (TableRowNode trn in tn.ChildNodes) { cCol = 0; foreach (TableCellNode tcn in trn.ChildNodes) { ParagraphNode pn = tcn.ChildNodes[0] as ParagraphNode; pn.SetText(string.Format("Ro {0}, Cel {1}", cRow, cCol)); cCol++; } cRow++; } } }
catch (Exception ex) {
} } private void ConstructHTMLTableWithColSpanForRichTextEditor() { try { string error = ""; xamrichtxtEditor.Document.RootNode.Body.ChildNodes.Clear(); TableNode tn = xamrichtxtEditor.Document.InsertTable(0, 7, 5, out error); tn.Settings = new TableSettings(); int cRow = 0, cCol = 0;
tn.Rows[1].Cells[1].Settings = new TableCellSettings { FitText = true, Wrap = true, ColumnSpan = 2, };
tn.Rows[1].Cells[3].Settings = new TableCellSettings { FitText = true, Wrap = true, ColumnSpan = 2, };
//Commented lines to look at //Note taht when cells which are column spanned are copied and pasted over a text editor or excel, //they are not getting pasted in teh same way, and thats not teh case with the contents copied without column spanned
} }
private void TextForXamRichTextEditor_Click(object sender, RoutedEventArgs e) { ConstructHTMLTableForRichTextEditor(); }
private void XamContextMenu_Loaded(object sender, RoutedEventArgs e) { List<object> itemsToRemove = new List<object>();
XamContextMenu menu = sender as XamContextMenu;
foreach (var x in menu.Items) { if (x is XamMenuItem) { XamMenuItem item = x as XamMenuItem; if (item.Header == null || !item.Header.ToString().Contains("Copy")) itemsToRemove.Add(item); } else itemsToRemove.Add(x); }
foreach (var y in itemsToRemove) menu.Items.Remove(y); }
private void TextForXamRichTextEditorWithColSpan_Click(object sender, RoutedEventArgs e) { ConstructHTMLTableWithColSpanForRichTextEditor(); } }}
And references used in my project:
InfragisticsWPF4.Controls.Editors.XamRichTextEditor.v16.1.dll
InfragisticsWPF4.Controls.Menus.XamMenu.v16.1.dll
InfragisticsWPF4.Documents.Core.v16.1.dll
InfragisticsWPF4.Documents.Excel.v16.1.dll
InfragisticsWPF4.Documents.RichTextDocument.Html.v16.1.dll
InfragisticsWPF4.Documents.RichTextDocument.Rtf.v16.1.dll
InfragisticsWPF4.Documents.RichTextDocument.v16.1.dll
InfragisticsWPF4.Documents.RichTextDocument.Word.v16.1.dll
Hope this helps, you can create a new project or in your existing project add a window and copy the contents i used in the xaml and xaml.cs file , and run the project referring this window.
NOTE: When cells which are col spanned, are copied and pasted on a text editor or excel spreadsheet , the values are not getting copied in teh same way as in the source.
Any update on this ?