我有疑问,当我们处理撤消(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
希望在系统中他们必须是这样一个机制。 我知道吗
buffer/stack
undo Operation
名称是什么?
vb.net
clipboard
代码访问
注意:代码不完整,但它可以按照我的意愿运行。