我给出了这样的代码:
Private Sub txtemployeename_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtemployeename.KeyDown
keyval = e.KeyData
Dim keyData As System.Windows.Forms.Keys = e.KeyData
If keyData = Keys.Down Then
LstEmployee.Visible = True
LstEmployee.Focus()
End If
End Sub
当我第一次单击未聚焦到列表框的向下箭头时,第二次单击聚焦的向下箭头..一旦光标到达列表框,如果我单击输入,则应显示在文本框中..为此我给了这样的代码..
Private Sub LstEmployee_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstEmployee.Enter
txtemployeename.Text = LstEmployee.SelectedItem
End Sub
但这不能正常工作..对于加载列表框,我给出了如下代码:
Private Sub txtemployeename_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtemployeename.KeyPress
Dim s As String = txtemployeename.Text
LstEmployee.Visible = True
loadlistbox(LstEmployee, "select Ename from EmployeeMaster_tbl where Ename LIKE'%" & s & "%' ")
End Sub