输入任何字符时,我需要自动填充文本框。Me.QuickSearchTableAdapter1.GetDataByFirstName(FirstNamePri.Text) 的查询是
SELECT firstNamePri FROM Customer WHERE (firstNamePri LIKE @firstName)
Private Sub FirstNamePri_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) 处理 FirstNamePri.KeyPress
Dim txtItems As New AutoCompleteStringCollection Dim search As ArfDynamicsDataSet.QuickSearchDataTable = _ Me.QuickSearchTableAdapter1.GetDataByFirstName(FirstNamePri.Text+"%") Dim dbValues As String For Each row As DataRow In search.Rows dbValues = row("firstNamePri").ToString() dbValues = dbValues.ToLower() txtItems.Add(dbValues) Next FirstNamePri.AutoCompleteCustomSource = txtItems End Sub
当我输入一个字符并且该字符在 db 中不存在时,文本框保持为空,并且我输入的字符也被删除
我选择了 AutoCompleteMode 来建议和 AutoCompleteMode 到 CustomSource
谁能解释我做错了什么。
编辑:如果我使用另一个文本框的按键事件说 TextBox1 并从 TextBox1 事件中自动填充 FirstNamePri 它可以工作。它应该在 FirstNamepri 的 keyPress 上工作
谢谢