如果是外部程序的文本框,找到文本框窗口句柄,发送WM_SETTEXT消息。
解决方案 »
- VB 获取系统当前输入法的浮动窗口
- 怎樣計算DataGrid數據行
- 有没有象Execl一样的控件
- 我做的一个纯DHTM的游戏,htm格式的,大家来看原代码!!
- 我的公司运转不景气,心情不妥,散分!
- 使用mciSendString播放wav,但是现在程序正常运行(mciSendString返回值非0)但是没有声音,这是为什么?
- [求助]用SQL完成如下数据库查询操作!
- 【★为什么会这样?难道微软很弱(有关datagrid的beforecolupdate)★】
- 水晶报表好用吗?各位大侠介绍一下经验。哪里有文档下.
- datacombo的问题,高手请进!!
- 请问如何能够对报表中的字段进行选择打印
- VB6报表打印问题,急!在线等待
APIVIEW默认的:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,lParam As Any) As Long改动后的:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long也就是最后的一个参数lParam 改为传址型的Dim Str As String
Str = "abcdef"
Call SendMessage(Text1.hwnd, WM_SETTEXT, Len(Str), Str)
Call SendMessage(Text1.hwnd, WM_SETTEXT, Len(Str), Str)要是想把一个串一个字一个字的输入到文本框里应该模拟键盘触发事件
keybd_event VK_A, 0, 0, 0 'press A
This is an AutoCompleting ComboBox that works with Data Bound or Regular ComboBoxes in VB.NET. As you type the case is preserved but the remaining text is auto filled by the list items. When the Leave function is called the case is fixed and the index from the list is also selected if there is a matching item. -------------------------------
Call the corresponding functions from your Combobox's KeyUp and Leave events like so:
Private Sub cboName_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cboName.Leave
Dim recRowView As DataRowView
Dim recName As DB.tblNameRow AutoCompleteCombo_Leave(cboName) 'OPTIONAL: Now you can do some extra handling if you want 'Get the Selected Record from my Data Bound Combo (Return Type is DataRowView)
recRowView = cboName.SelectedItem
If recRowView Is Nothing Then Exit Sub 'Display the Name Info (Row Type comes from my bound Dataset)
recName = recRowView.Row
lblAccountNum.Text = recName.AccountNum
lblCompanyName.Text = recName.CompanyNameEnd SubPrivate Sub cboName_KeyUp(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboName.KeyUp AutoCompleteCombo_KeyUp(cboName, e)End Sub
----------------------------
Here are the Generic Functions for handling the events:
Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String 'Allow select keys without Autocompleting
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down
Return
End Select 'Get the Typed Text and Find it in the list
sTypedText = cbo.Text
iFoundIndex = cbo.FindString(sTypedText) 'If we found the Typed Text in the list then Autocomplete
If iFoundIndex >= 0 Then 'Get the Item from the list (Return Type depends if Datasource was bound
' or List Created)
oFoundItem = cbo.Items(iFoundIndex) 'Use the ListControl.GetItemText to resolve the Name in case the Combo
' was Data bound
sFoundText = cbo.GetItemText(oFoundItem) 'Append then found text to the typed text to preserve case
sAppendText = sFoundText.Substring(sTypedText.Length)
cbo.Text = sTypedText & sAppendText 'Select the Appended Text
cbo.SelectionStart = sTypedText.Length
cbo.SelectionLength = sAppendText.Length End IfEnd Sub
Public Sub AutoCompleteCombo_Leave(ByVal cbo As ComboBox)
Dim iFoundIndex As Integer iFoundIndex = cbo.FindStringExact(cbo.Text) cbo.SelectedIndex = iFoundIndexEnd Sub