我有疑问,当我们处理撤消( ctrl+z
)时,从哪里复制值? 价值暂时持有的地方? 它不在clipboard
是他们的东西像clipboard
或buffer
?
对于一个文本框,我可以通过使用堆栈来设置100个回退undo operation
。 以下是在vb.net中执行的代码:
Dim undoStack(100) As String ' stack array Dim stackTop As Integer = 0 ' stack counter Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If stackTop < 100 Then ' 100 step back undoStack ' system will perform the operation when use ctrl+z for undoStack ' so i choose f1 key for undoStack to check the code If e.KeyCode = Keys.F1 And stackTop > 0 Then ' check whether the key is F1 and stack is empty or not TextBox1.Text = undoStack(stackTop - 1) 'load lst change to the text box from stack undoStack(stackTop) = Nothing ' clear the stack top value stackTop -= 1 ' decrement the stack top by 1 ElseIf TextBox1.Text <> undoStack(stackTop) Then undoStack(stackTop) = TextBox1.Text ' push value to stackTop stackTop += 1 'Increment the stackTop End If Else ' call function to perform left shift ' insert change in last position End If End Sub
希望在制度上它们必须是这样一个机制。 我可否知道
undo Operation
的buffer/stack
的名称 clipboard
一样的vb.net
代码访问 注:代码不完整,但它的function,我希望。