in RichTextBox control it offers that i can add new comment for selected test by InsertCommentCommand function
how can i custom this comment by adding a custom user control instead of text control that i put my comment inside it?
thanks every one.
14 Answers, 1 is accepted
The content of the comments is actually a RadDocument and it is visualized by a RadRichTextBox instance that is shown in the comment balloon. Inserting user controls instead of comments is not a scenario we currently support.
Alex
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
We are using RadRichTextBox (for WPF). Could you please help on below issue :
1) If we set myRadRichTextBox.LayoutMode = DocumentLayoutMode.Paged; then comment pane is displayed properly (and not getting collapsed).
Please refer to the attachment "PagedLayout_CommentPane.png"
2) If we set myRadRichTextBox.LayoutMode = DocumentLayoutMode.Flow; then comment pane is getting collapsed.
Please refer to the attachment "FlowLayout_CommentPane.png". Could you please help me to solve this, because currently for our Business Purpose, we are planning to have "Flow" Mode with comments. Thanks. Obuliraj R
Thank you for contacting us.
I can confirm that the problem exists and have opened bug report item in our feedback portal where you could upvote and track the overall progress of the issue.
Regards,
Mihail
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
You can insert content in a comment as soon as it is added to the document by subscribing to the CommandExecuted event. For example, obtain the comment and create a RadDocumentEditor for it like this:
void
radRichTextBox_CommandExecuted(
object
sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
{
if
(e.Command
is
InsertCommentCommand)
{
var commentEnd =
this
.radRichTextBox.Document.Selection.GetAnnotationMarkersOfType<CommentRangeEnd>().First();
RadDocumentEditor editor =
new
RadDocumentEditor(commentEnd.Comment.Body);
string
username =
"Anonymous"
;
if
(
this
.radRichTextBox.CurrentUser !=
null
)
{
username =
this
.radRichTextBox.CurrentUser.Username;
}
editor.Insert(username +
" at "
+ DateTime.Now);
}
}
Focusing the comment is not possible at this point, although making this the default behavior is already in our backlog. You can track the status of the feature through this item in the public portal.
Regards,
Petya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Could you please help us to achieve "Expected Result"
Steps:
1. Type Text “Parent (Child) Comment” in the Editor
2. Select all text and insert new comment. Comment gets created.
3. Select only “Child” word from text “Parent (Child) Comment” and insert new comment. Comment gets created.
4. Select “Comment” Balloon for word “Child” to select it (green thick line will appear)
5. Click delete comment button
Expected Result:
Since the comment balloon for word “Child” was selected in UI, it should be deleted
Actual Result:
The comment for text “Parent (Child) Comment” gets deleted. Ideally selected comment should be deleted. This appears to be a problem when comments are nested. The delete comment deletes the incorrect comment.
Please refer to the attachment "Delete Comment - Issue.png"
Thanks,
Obuliraj Ramalingam
Thank you for contacting us.
I managed to reproduce the reported issue and logged it in our backlog. You can track its state from the following feedback item: Deleting nested comment annotations deletes the outer-most first.
As a workaround I would suggest you to implement your own command, which calls the following methods to delete a comment:
private void DeleteActiveComment()
{
Inline inline = GetInlineFromCaretPositionOrSelection(this.radRichTextBox.Document);
var comment = this.radRichTextBox.Document.GetContainingAnnotationRanges<
CommentRangeStart
>(inline, true).LastOrDefault();
if (comment != null)
{
this.radRichTextBox.DeleteComment(comment);
}
}
public static Inline GetInlineFromCaretPositionOrSelection(RadDocument document)
{
InlineLayoutBox inlineBox = null;
if (document.Selection.IsEmpty)
{
inlineBox = document.CaretPosition.GetCurrentInlineBox();
}
else
{
SelectionRange lastRange = document.Selection.Ranges.Last;
if (lastRange.IsReversed)
{
inlineBox = lastRange.EndPosition.GetCurrentInlineBox();
}
else
{
inlineBox = lastRange.StartPosition.GetCurrentInlineBox();
}
}
if (inlineBox != null)
{
return inlineBox.AssociatedInline;
}
else
{
return null;
}
}
I hope this information is helpful. Let me know if you need further assistance.
Regards,
Svetoslav
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thanks for your time & sample code. I have tried this approach. Sorry, still there is an issue:
1) If I select "parent" comment & delete it, it's deleting respective "parent" comment.
2) If I select "child" comment & delete it, then it's deleting both "parent" and "child" comments.
So, (1) is working like expected and (2) is not.
Could you please try to duplicate this scenario & help us.
Thanks,
Obuliraj Ramalingam
I was able to delete the comments in any desired order (from inner to outer and vice versa) by using the provided code-snippet in the previous post from Svetoslav. Please ensure you the custom command is not executed twice.
For your convenience, I've created a sample demo project which illustrates the suggested approach. You can find it attached. It will be great if you modify the sent project in a way the issue can be reproduced and send it back to us.
Looking forward to your reply.
Regards,
Todor
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thanks for the sample code.
Now it's working like expected.
Thanks,
Obuliraj Ramalingam
Could you please clarify me on below scenario :
Steps :
1) Copied large text from Word document and pasting to RadRichTextBox.
2) Selected particular word and clicked "Insert Comment" button
3) New comment is inserted, however the focus is not staying in selected text nor (newly inserted) comment
4) If I manually scroll to the selected text, then I am able to see the (newly inserted comment).
5) For further selection, Insert comment is working fine
Issue :
Could you please suggest a way to solve issue in step 3)
Trials from my side:
I tried to call following methods, but they are not working
myRadRichTextBox.UpdateLayout();
myRadRichTextBox.UpdateEditorLayout();
myRadRichTextBox.Focus();
if (myRadRichTextBox.ActiveEditorPresenter != null)
{
myRadRichTextBox.ActiveEditorPresenter.RecreateUI();
}
Thanks,
Obuliraj Ramalingam
"1 - Insert comment for first time.png"
"2 - Scroll to particular text.png"
I was not able to reproduce the described issue, nor with the sample application we sent you, nor with other simple application. On our side, the focus is property returned to the Main document body (as expected) where the newly inserted comment is automatically selected.
I would suggest you to open separate support ticket, where you would be able to attach sample application reproducing the issue. This way we will be able to investigate the issue further.
Regards,
Boby
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I am able to fix this issue using following code segment.
private void myRadRichTextBox_CommentShowing(object sender, CommentShowingEventArgs e)
{
if (e.Comment.Body.IsEmpty)
{
myRadRichTextBox.Document.GoToComment(e.Comment);
}
}
private void myRadRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
if (e.Command is InsertCommentCommand)
{
myRadRichTextBox.ActiveEditorPresenter.RecreateUI();
}
}
Thanks,
Obuliraj Ramalingam