Click here to Skip to main content
15,891,529 members
Articles / Desktop Programming / Windows Forms

Undo/Redo Framework

Rate me:
Please Sign up or sign in to vote.
4.89/5 (21 votes)
16 Oct 2013CPOL8 min read 93.3K   4.2K   78  
Undo/Redo framework for editing controls in a Windows application.
Public Class Form1

    Private WithEvents frmUndoRedoManager As UndoRedoManager

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        frmUndoRedoManager = New UndoRedoManager(Me, txtRedo, txtUndo)
        MessageBox.Show(frmUndoRedoManager.GetRegisteredUndoRedoMonitorTypes())
    End Sub

    Private Sub BtnUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUndo.Click
        frmUndoRedoManager.Undo()
    End Sub

    Private Sub BtnRedo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRedo.Click
        frmUndoRedoManager.Redo()
    End Sub

    Private Sub frmUndoRedoManager_CanRedoChanged(ByVal Sender As Object, ByVal CanRedo As Boolean) Handles frmUndoRedoManager.CanRedoChanged
        btnRedo.Enabled = CanRedo
    End Sub

    Private Sub frmUndoRedoManager_CanUndoChanged(ByVal Sender As Object, ByVal CanUndo As Boolean) Handles frmUndoRedoManager.CanUndoChanged
        btnUndo.Enabled = CanUndo        
    End Sub

    Private Sub frmUndoRedoManager_UndoRedoStacksChanged(ByVal Sender As Object) Handles frmUndoRedoManager.UndoRedoStacksChanged
        txtRedo.Text = vbCrLf & frmUndoRedoManager.GetRedoStack
        txtUndo.Text = vbCrLf & frmUndoRedoManager.GetUndoStack
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Netherlands Netherlands
Currently working as a Software Developer on several projects.

Comments and Discussions