How can we make a List of the Comments. Read the contains of those 'Comments' and determine which 'two words' were selected for each Comment?
3 Answers, 1 is accepted
Thank you for your question. Please see below how you can perform each of the two requests - get the text in the big document, which is being commented on and get the text of the comments themselves:The code in the snippet uses TxtFormatProvider, which will retrieve the documents' content stripped of formatting. You can choose any of the format providers, depending on the processing you will be performing afterwards. Best wishes,
the Telerik team
I'm attempting to understand how to combine the 'selected text' plus 'comments' and display those results in a datagrid as seen in the code below. My method is too generic to succeed. Is there another method to get the selection? Any suggestions are appreciated.
private IEnumerable<List<string>> SelectedTextAndCommentBody()
List<string> list = new List<string>(2); // List constructor
IEnumerable<CommentRangeStart> comments = this.cuftEditor.Document.EnumerateChildrenOfType<CommentRangeStart>();
foreach (CommentRangeStart comment in comments)
TxtFormatProvider cuftFormatProvider = new TxtFormatProvider();
CommentRangeEnd commentEnd = comment.End as CommentRangeEnd;
RadDocument commentBody = commentEnd.Comment.Body;
string plainText = myFormatProvider.Export(commentBody);
RadDocument document = this.myEditor.Document.Selection.CreateDocumentFromSelection();
string plainText2 = myFormatProvider.Export(document);
string csv = plainText + "," + plainText2;
string parts = csv.Split(',');
yield return list;
listOfActionableItems.ItemsSource = SelectedTextAndCommentBody();
I am not sure if I understand what are you trying to achieve, but it looks like a question of proper data binding of data grid to list of data objects. SelectedTextAndCommentBody can, for example, return a list of custom class (or event Tuple) containing the information you need – namely comment body and comment range text – then you can bind the data grid columns to the properties of the custom class.
Please get back to us if you need further assistance.
the Telerik team