8

I want to disable undo redo feature of textbox and richtextbox. Please tell how to do this.

Abhi
  • 5,501
  • 17
  • 78
  • 133
  • 2
    Why would you want to do that? – Daniel Hilgarth Jul 18 '11 at 12:05
  • 2
    I can think of a couple really good reasons. 1) memory usage, 2) performance, 3) annoy the users. – GalacticCowboy Jul 18 '11 at 12:17
  • Here's one I'm currently dealing with: disabling redo and undo in MaskedTextBox. It's just too much of a pain to implement (at least in WPF since you basically have to re-implement redo and undo and put the caret back in the right place every time); not worth it at all since they will probably never even get used. I know of 2 reputable sources that disable these functions in their masked textboxes: 1) [jQuery](http://digitalbush.com/projects/masked-input-plugin/), 2) [Syncfusion](http://www.syncfusion.com/prducts/wpf/masked-text-box), also 3) this textbox that I'm typing in (not masked though) – Daniel Ward Jun 10 '14 at 21:53

2 Answers2

18

You can use the IsUndoEnabled property:

<TextBox Name="yourTextBox" IsUndoEnabled="False" />
Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
5

Set the UndoLimit property of your Textbox to 0. Should work.

Mariusz
  • 1,409
  • 12
  • 25