473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Undo,Redo functionalities for Designer host not working

Hi All,

I want to perform basic Edit menu functionalities on my custom design surface.
While all the Cut/Copy/Paste/Deelete/Select functionalities working fine with code below,Undo/Redo standard commands are not working for me.

Expand|Select|Wrap|Line Numbers
  1. IMenuCommandService menusrv= HostControl.HostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
  2.              if (menusrv != null)
  3.              {
  4.                  switch (editstring)
  5.                  {
  6. ////////////////////////////////////////////
  7. //Undo/Redo not working    ////
  8. //////////////////////////////////////////
  9.                      case "Undo/Redo":
  10.                        menusrv.GlobalInvoke(StandardCommands.undo/StandardCommands.Redo)
  11. break;
  12.  
  13.                       case "Cut":
  14.                          menusrv.GlobalInvoke(StandardCommands.Cut);
  15.                          break;
  16.                      case "Copy":
  17.                          menusrv.GlobalInvoke(StandardCommands.Copy);
  18.                          break;
  19.                      case "Paste":
  20.                          menusrv.GlobalInvoke(StandardCommands.Paste);
  21.                          break;
  22.                      case "Delete":
  23.                          menusrv.GlobalInvoke(StandardCommands.Delete);
  24.                          break;
  25.                      case "SelectAll":
  26.                          menusrv.GlobalInvoke(StandardCommands.SelectAll);
  27.                          break;
  28. }
  29. }
It will be of great help if sumbody can share a piece of code to implement Undo/Redo functionalitis.

I am using .NET 2003,C#
Help will be much appreciated!

Thanks and Regards,
-Anupam Roy
Feb 13 '08 #1
1 4022
kenobewan
4,871 Expert 4TB
This example may help:

Undo and redo commands in the constructor

Expand|Select|Wrap|Line Numbers
  1. AddCommand(new MenuCommand(new EventHandler(this.ExecuteUndo), StandardCommands.Undo));
  2.  
  3. AddCommand(new MenuCommand(new EventHandler(this.ExecuteRedo), StandardCommands.Redo));
  4.  
  5. void ExecuteUndo(object sender, EventArgs e)
  6.  
  7. {
  8.  
  9. UndoEngineImpl undoEngine = _host.GetService(typeof(UndoEngine)) as UndoEngineImpl;
  10.  
  11. if (undoEngine != null)
  12.  
  13. undoEngine.DoUndo();
  14.  
  15. }
  16.  
  17. void ExecuteRedo(object sender, EventArgs e)
  18.  
  19. {
  20.  
  21. UndoEngineImpl undoEngine = _host.GetService(typeof(UndoEngine)) as UndoEngineImpl;
  22.  
  23. if (undoEngine != null)
  24.  
  25. undoEngine.DoRedo();
  26.  
Feb 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jay | last post by:
I need to implement an undo and redo for an entire row in a listview containing approximately 10 columns. I'm not sure of the best way to implement this. The only thing that I've thought of is a...
1
by: black | last post by:
I'm coding with Tkinter and i wonder whether we could get current OS' clipboard available, and event more, anyone can inspires me how we can achieve undo and redo function ? thanx~ ...
6
by: lkrubner | last post by:
I'm offering users the ability to type weblog posts into a form and post them. They type the text into a TEXTAREA which is on a form. The form, when submitted, hits a PHP script. Before it is...
3
by: babylon | last post by:
any facilities in csharp that can help me implmenting undo/redo in my application? thx
3
by: Teis Draiby | last post by:
I'm looking for some information (books, articles, tutorials) on how to implement a multiple undo/redo framework. I'm a beginner in this so I prefer information specifically targeting C# with code...
1
by: Alan | last post by:
Hi all, I'm programming one VBScript Editor with syntax hilighting. I use the RichTextBox control. Although the syntaxhilighting function comes true, i found the undo/redo function didn't work. I...
2
by: Christian H | last post by:
Hello, I've tried to find information about how to implement an Undo/Redo pattern. This article describes such a pattern: http://www.codeproject.com/csharp/PcObjectUndo.asp , but is a little bit...
0
by: wizard of oz | last post by:
Hi all, I'm extending an Abstract Styled Document associated with a JTextPanel to implement a syntax highlighting editor. This is all working just fine - except for undo / redo. The problem...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.