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

Undo and Redo buttons

1 Answer 102 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Artur
Top achievements
Rank 1
Artur asked on 22 Jul 2010, 10:28 AM
Hi,

I have a RadRichTextBoxRibbonUI with an RadRichTextBox. Inside of the RadRichTextBoxRibbonUI i have 6 RadRibbonButtons: copy, paste, cut, undo and redo. What i want to do is to disable this buttons if it isn't possible to do the action.
Example: if i can't do more Undo.


I don't know if it is possible, but i already try everything and i couldn't do.

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 23 Jul 2010, 01:33 PM
Hello Artur,
Unfortunately these build-in commands does not support this behavior out-of-the-box. I will add this in our to-do list.
You can, however, implement this by yourself, and I will give give you a few hints.
  • For updating Undo and Redo buttons, you may attach to DocumentContentChanged event of RadRichTextBox. In the handler, you may update the state of the buttons like this:
    buttonUndo.IsEnabled = radRichTextBox1.Document.History.CanUndo;
    buttonRedo.IsEnabled = radRichTextBox1.Document.History.CanRedo;
  • For updating Copy and Paste buttons, you may attach to SelectionChanged event of DocumentSelection class:
    radRichTextBox1.Document.Selection.SelectionChanged += Selection_SelectionChanged;
    In the handler, you may update the state of the buttons like this:
    bool isSelectionEmpty = radRichTextBox1.Document.Selection.IsEmpty;
    buttonCopy.IsEnabled = !isSelectionEmpty;
    buttonCut.IsEnabled = !isSelectionEmpty;
  • For the Paste button updating will be tricky, because you have to decide by yourself when to update the state of the button. You can try using the methods of Silverlight's Clipboard class.

All the best,
Boby
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Artur
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or