如何自动将VB中的Combo的下拉菜单打开?

iamdan 2002-12-23 11:37:23
如何自动将VB中的Combo的下拉菜单打开?
我需要一增量查询的东西,比如当用户输入ab时,Combo的菜单就应该自动打开并显示ab1,ab4等,请问如何实现?
...全文
465 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
litsnake1 2002-12-23
  • 打赏
  • 举报
回复
上面的方法可以
也可以试试
combo1.setfocus
sendkeys "{f4}"
nik_Amis 2002-12-23
  • 打赏
  • 举报
回复
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 Const CB_SHOWDROPDOWN = &H14F

Public Sub ComboBox_DropDown(ByVal hWnd As Long)
SendMessage hWnd, CB_SHOWDROPDOWN, -1, ByVal 0
End Sub
softwaredream 2002-12-23
  • 打赏
  • 举报
回复
Public Sub ComboBox_DropDown(ByVal hWnd As Long)
SendMessage hWnd, CB_SHOWDROPDOWN, -1, ByVal 0
End Sub
??没有任何反应的
fzn0621 2002-12-23
  • 打赏
  • 举报
回复
用combobox弹出下拉菜单后,所有鼠标、键盘的输入都被捕捉到了弹出的菜单中。也就是说一旦弹出菜单,你就不能在在combo的text框中输入数据了。
所以,我建议你用textbox和listbox代替combobox好了。。(listbox来模拟下拉菜单)
superlly 2002-12-23
  • 打赏
  • 举报
回复
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox

'Required by the Windows Form Designer
Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.DropDownWidth = 96
Me.ComboBox1.Location = New System.Drawing.Point(176, 80)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(96, 20)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ComboBox1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub



Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
SendMessage myCombo.hWnd, CB_SHOWDROPDOWN, -1, ByVal 0


End Sub

of123 2002-12-23
  • 打赏
  • 举报
回复
这个函数这样写是否好懂些:
Public Sub ComboBox_DropDown(ByVal myCombo As Control)
SendMessage myCombo.hWnd, CB_SHOWDROPDOWN, -1, ByVal 0
End Sub

调用:
ComboBox_DropDown Combo1
beanbaby2002 2002-12-23
  • 打赏
  • 举报
回复


还是建议你用LISTBOX实现这个功能,这个API什么什么的,我到现在还没有搞懂。

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧