Undo and Redo in c#
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
Here are some articles: http://www.codeproject.com/useritems/useractionbasedundoredo.asp http://www.codeproject.com/csharp/autoundoredo.asp and this pattern looks promising too: http://en.wikipedia.org/wiki/Memento\_pattern Although they will not be easy to implement with a RichTextBox I think. A simple solution, that comes to my mind would be to save a copy of of the text when a change occurs. Then you can undo by replacing the current one with this copy. You should however limit the number of copies because it will consume a lot of memory when there is a lot of text. Can you show us what you have thought of, or have tried already? Do you have a specific problem, or just no idea where to start? I feel like a twat :p I didn't know RichTextbox has Undo/Redo functionality. Post your code, tell us what the problem is. -- modified at 10:38 Wednesday 21st March, 2007
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
Before you try to Undo something, you need to check to see whether or not it can be undone. To do this, you need to call CanUndo and only call Undo if it returns true. Similar logic applies to Redo/CanRedo.
Deja View - the feeling that you've seen this post before.
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
Search the articles for "undo" and/or "redo". There are some that cover this topic.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
hi, I am creating a editor in Richtextbox control. and now i want to implement feature Undo and redo .. I am not getting it. pls help me with regards prasad:)
I could only find an example in VB. http://www.java2s.com/Code/VB/GUI/RichTextBoxReDoandUnDo.htm this is my own mockup
private void button1_Click(object sender, EventArgs e) { if(richTextBox1.CanUndo) { richTextBox1.Undo(); } } // this is just to show the UndoActionName property... private void richTextBox1_TextChanged(object sender, EventArgs e) { button1.Text = richTextBox1.UndoActionName; }
It seems to work fine here.
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
Here are some articles: http://www.codeproject.com/useritems/useractionbasedundoredo.asp http://www.codeproject.com/csharp/autoundoredo.asp and this pattern looks promising too: http://en.wikipedia.org/wiki/Memento\_pattern Although they will not be easy to implement with a RichTextBox I think. A simple solution, that comes to my mind would be to save a copy of of the text when a change occurs. Then you can undo by replacing the current one with this copy. You should however limit the number of copies because it will consume a lot of memory when there is a lot of text. Can you show us what you have thought of, or have tried already? Do you have a specific problem, or just no idea where to start? I feel like a twat :p I didn't know RichTextbox has Undo/Redo functionality. Post your code, tell us what the problem is. -- modified at 10:38 Wednesday 21st March, 2007
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
hi, int ActiveUndoIndex = ActiveWindowStatus(); if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true) { arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo(); arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo(); } this code is undoing the enitre actions not chracter by chracter ... help me pls
-
Before you try to Undo something, you need to check to see whether or not it can be undone. To do this, you need to call CanUndo and only call Undo if it returns true. Similar logic applies to Redo/CanRedo.
Deja View - the feeling that you've seen this post before.
hi, int ActiveUndoIndex = ActiveWindowStatus(); if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true) { arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo(); arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo(); } this is undoing the entire operation e.g if i enter 100 chracters it is deleting 100 chracters at time for single undo..
-
I could only find an example in VB. http://www.java2s.com/Code/VB/GUI/RichTextBoxReDoandUnDo.htm this is my own mockup
private void button1_Click(object sender, EventArgs e) { if(richTextBox1.CanUndo) { richTextBox1.Undo(); } } // this is just to show the UndoActionName property... private void richTextBox1_TextChanged(object sender, EventArgs e) { button1.Text = richTextBox1.UndoActionName; }
It seems to work fine here.
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
hi, int ActiveUndoIndex = ActiveWindowStatus(); if (arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.CanUndo == true) { arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.Undo(); arrScrptDsgnrFrms[ActiveUndoIndex].RchtxtBx.ClearUndo(); } this is undoig all entered characters at single shot e.g if i enter 100 charcters all 100 chractes are removing at a single shot.