Private Sub Text1_Change()
在屏南等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计、成都网站制作 网站设计制作按需网站开发,公司网站建设,企业网站建设,品牌网站制作,成都全网营销,外贸网站制作,屏南网站建设费用合理。
For x = 0 To List1.ListCount - 1
If Text1.Text = List1.List(x) Then
List1.Selected(x) = True
End If
Next x
End Sub
假如Form1有个TextBox1,双击TextBox1填入123
Public Class Form1
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
System.Windows.Forms.SendKeys.Send("123")
End Sub
End Class
看你的VB.NET 版本了
用 My.Computer.Keyboard.SendKeys("123", True) 代替 System.Windows.Forms.SendKeys.Send("123") 也可以
原码:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
My.Computer.Keyboard.SendKeys("123", True)
End Sub
End Class
有甚多办法,我说个最简单的
dim xstr as string = "abcde"
Xstr = "(" xstr ")"
dim Userlist() as string
redim Userlist(10)
for i=0 to 10
userlist(i) = i
Next
这样就行
Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If cmb.DataSource Is Nothing Then
Return
End If
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
Return
End If
Dim strFindStr As String = ""
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Back) Then
If (cmb.SelectionStart = cmb.Text.Length) Then
If cmb.Text.Length 0 Then
strFindStr = cmb.Text.Substring(0, cmb.Text.Length - 1)
End If
Else
If cmb.SelectionStart 0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1)
End If
End If
e.Handled = False
Else
If (cmb.SelectionLength = 0) Then
strFindStr = cmb.Text + e.KeyChar
Else
If (cmb.SelectionStart = cmb.Text.Length) Then
strFindStr = e.KeyChar
Else
If cmb.SelectionStart 0 Then
strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1) + e.KeyChar
Else
strFindStr = e.KeyChar
End If
End If
End If
End If
Dim intIdx As Integer = -1
Dim dv As DataView
If TypeOf (cmb.DataSource) Is DataTable Then
dv = CType(cmb.DataSource, DataTable).DefaultView
If strFindStr "" Then
dv.RowFilter = cmb.DisplayMember " Like '%" strFindStr "%'"
Else
dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
Else
dv = CType(cmb.DataSource, DataView)
If strFindStr "" Then
dv.RowFilter = cmb.DisplayMember " Like '%" strFindStr "%'"
Else
dv.RowFilter = ""
End If
cmb.DataSource = dv
cmb.SelectedIndex = -1
cmb.Text = strFindStr
End If
cmb.SelectionStart = strFindStr.Length
e.Handled = True
End Sub
Private Sub comboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comboBox1.KeyPress
AutoComplete(sender, e)
End Sub