KeyDown
If e.KeyCode = Keys.Enter Then
Dim t As Table = e.Form.Controls("Table1").Table
With t
If e.Sender.Text <> "" Then
.StopRedraw
.filter = "第一列 like '%" & e.Sender.Text & "%'"
.ResumeRedraw
Else
e.Form.Controls("Table1").Table.filter = ""
End If
End With
End If
如果还有其他控件,又不想焦点离开本查询框:
If e.KeyCode = Keys.Enter Then
e.Cancel = True
Dim t As Table = e.Form.Controls("Table1").Table
With t
If e.Sender.Text <> "" Then
.StopRedraw
.filter = "第一列 like '%" & e.Sender.Text & "%'"
.ResumeRedraw
Else
e.Form.Controls("Table1").Table.filter = ""
End If
End With
End If
e.Sender.Select