ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2014-12-30 23:16:09

asparatu
Member
Registered: 2014-08-20
Posts: 196

How can you track undo and redo actions

I would like to know, how can track the undo and redo action, so i can update toolbar buttons?

Thank you
Shane

Last edited by asparatu (2014-12-31 00:47:57)

Offline

#2 2014-12-31 00:47:02

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: How can you track undo and redo actions

The following two methods are used to check whether or not there are any actions in stack:

  grid.CanUndo()
  grid.CanRedo()

And for monitor the actions performing, undoing and redoing, the following three events can be used to do that:

AddHandler grid.ActionPerformed, Sub(s, args)
                         MsgBox("Action Performed")
                       End Sub

AddHandler grid.Undid, Sub(s, args)
                         MsgBox("Undid")
                       End Sub

AddHandler grid.Redid, Sub(s, args)
                         MsgBox("Redid")
                       End Sub

Last edited by Jingwood (2014-12-31 00:51:56)

Offline

#3 2014-12-31 00:49:29

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: How can you track undo and redo actions

Hello Jing,
   Thank you.. I was editing my question as you were answering it.. hehe

Shane

Offline

#4 2014-12-31 00:51:44

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: How can you track undo and redo actions

Jing,
   Can that tell me if there is any items left in the stack? so, i can disable or enable the buttons?
Shane

Edit: You answered it already..hehe

Last edited by asparatu (2014-12-31 00:55:08)

Offline

#5 2014-12-31 00:52:31

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: How can you track undo and redo actions

I've just updated my answer for check actions:)

You asked a nice question, I think there should be a document to describe how to use actions in ReoGrid.

Last edited by Jingwood (2014-12-31 00:54:57)

Offline

#6 2014-12-31 00:58:08

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: How can you track undo and redo actions

Thank you..

I also seen that is on the worksheet .cancopy, .canpaste, .cancut also.. would that be use in the same way?

Shane

Offline

#7 2014-12-31 00:59:41

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: How can you track undo and redo actions

Yes, it's same usage. I use them in ReoGridEditor.

Offline

#8 2014-12-31 01:06:30

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: How can you track undo and redo actions

Jing,
   Would this work

ddHandler rgMainControlContainer.Undid, Sub(s, args)
                                                     If rgMainControlContainer.CanUndo = True Then
                                                         tbbUndo.Enabled = True
                                                     Else
                                                         tbbUndo.Enabled = False
                                                     End If
                                                 End Sub

or would this be better

 AddHandler rgMainControlContainer.Undid, Sub(s, args)
                                                     tbbUndo.Enabled = rgMainControlContainer.CanUndo()
                                                 End Sub

this the code for the Function for the undo and redo
As you can see i am checking to see if the grid is active control and doing undo and redo base on that..but i didnt have way to update the buttons, It work fine with short cut keys.

Private Function Undo() As Boolean
        Undo = False

        If rgMainControlContainer.Name = Me.ActiveControl.Name Then
            rgMainControlContainer.Undo()
            Undo = True
        Else
            frmUndoRedoManager.Undo()
            Undo = True
        End If
    End Function

    Private Function Redo() As Boolean
        Redo = False

        If rgMainControlContainer.Name = Me.ActiveControl.Name Then
            rgMainControlContainer.Redo()
            Redo = True
        Else
            frmUndoRedoManager.Redo()
            Redo = True
        End If
    End Function

Last edited by asparatu (2014-12-31 01:14:02)

Offline

#9 2015-01-01 02:37:52

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: How can you track undo and redo actions

asparatu wrote:

As you can see i am checking to see if the grid is active control and doing undo and redo base on that..but i didnt have way to update the buttons

Maybe you could use this:

AddHandler grid.LostFocus, Sub(s, args) Button1.Enabled = False
AddHandler grid.GotFocus, Sub(s, args) Button1.Enabled = True

Offline

Board footer

Powered by FluxBB