Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Multiple Undo/Redo


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008, 02:45 AM
Senior Member
 
Join Date: May 2007
Posts: 126
Default Multiple Undo/Redo

What are nice ways to implement multiple undo and redo on applications like
text editor or table entries?
__________________
Rioven

O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded)
Reply With Quote
  #2 (permalink)  
Old 05-13-2008, 05:48 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,572
Default

The following code implements multiple Undo in a table.
This code will not work if the value of a cell contains a comma.
You can change it to work with some other character like tilde (~) instead.
alStack is an ArrayList.
Code:
Sub Globals
    'Declare the global variables here.
    Dim Type(Column,Row,Value) UndoItem
End Sub

Sub App_Start
    Form1.Show
    FillTable
End Sub

Sub FillTable
    Table1.AddCol(cString,"Col 1",50)
    Table1.AddCol(cString,"Col 2",50)
    Table1.AddCol(cString,"Col 3",50)
    For i = 1 To 10
        Table1.AddRow(i,i,i)
    Next
End Sub

Sub AddItem (column,row,oldValue)
    alStack.Insert(0,column & "," & row & "," & oldValue)
End Sub

Sub UndoLast
    If alStack.Count = 0 Then Return 'No items
    UndoItem() = StrSplit(alStack.Item(0),",")
    alStack.RemoveAt(0)
    Table1.Cell(UndoItem.Column,UndoItem.Row) = UndoItem.Value
End Sub

Sub btnChange_Click
    col = Table1.SelectedCol
    row = Table1.SelectedRow
    AddItem(col,row,Table1.Cell(col,row)) 'Save the previous value
    Table1.Cell(col,row) = txtChange.Text
End Sub
Sub btnUndo_Click
    UndoLast
End Sub
Reply With Quote
  #3 (permalink)  
Old 05-15-2008, 08:41 AM
Senior Member
 
Join Date: May 2007
Posts: 126
Default

Hi Erel, Thanks for this useful sample code for table.
__________________
Rioven

O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded)
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Serial connections? cwtoyota Questions & Help Needed 1 05-23-2008 11:05 AM
Deleting multiple files at ones sonavep Questions & Help Needed 2 04-21-2008 03:00 PM
Multiple Listviews tsteward Questions & Help Needed 2 04-20-2008 10:16 AM
Multiple Instances of an application Louis Questions & Help Needed 1 12-23-2007 05:20 AM
Undo in the designer Mistrel Basic4ppc Wishlist 1 10-13-2007 06:46 AM


All times are GMT. The time now is 03:58 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0