level 11
Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
Dim findstr As String, n As Integer
findstr = TextBox1.Text
n = ListBox1.FindStringExact(findstr)
If e.KeyChar = Chr(13) Then
If n >= 0 Then
ListBox1.SetSelected(n, True)
Else
If ListBox1.SelectedIndex >= 0 Then
ListBox1.SetSelected(ListBox1.SelectedIndex, False)
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End If
End If
End If
End Sub
2014年01月06日 06点01分
4
level 11
我想使textbox中的文本在按下回车后添加到listbox并清空textbox可是我编完后按回车没反应?!
2014年01月06日 06点01分
5
level 10
在控件的 keydown 事件中而不要在 keypress 事件中检测
2014年01月14日 06点01分
12
3q,以解决
2014年01月14日 11点01分
level 2
你这是文本框的按键事件,你是不是想‘在按下键盘某键时触发此事件’但前提是这个文本框必须得到了焦点才能触发这个事件!
2014年03月04日 17点03分
13