文本框删除按钮不撤消

时间:2014-10-25 19:31:55

标签: vb.net

基本上,下面的代码会从文本框中删除所选文本,但您无法将其撤消。有关使其撤消的任何帮助吗?

TextBox1.SelectedText = ""

2 个答案:

答案 0 :(得分:0)

尝试以下内容的变体......

Public Class Form1
    Dim selText as String

    Private Sub Button1_Click(sender as object, e as EventArgs) Handles Button1.Click
        selText = TextBox1.SelectedText
        TextBox1.SelectedTexxt = ""
    End Sub

    Private Sub Button2_Click(sender as object, e as EventArgs) Handles Button2.Click
        TextBox1.AppendText(selText)
    End Sub
End Class

答案 1 :(得分:-2)

找到答案。只需使用下面的代码

SendKeys.Send("{BS}")