如何让COMBOBOX控件自动展开?

howel 2003-04-24 01:31:17
当组合框获得焦点后,自动展开其内容,而不用点右边的三角形?
...全文
317 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhoujianfengren 2003-04-27
up
回复
loveerror 2003-04-24
同意上面的。 没什么好说的了。
回复
rainstormmaster 2003-04-24
兄弟,没错。不过,要事先声明函数和常量,像下面:
Option Explicit
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
Private Sub Command1_Click()
'Me.Combo1.SetFocus
SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, True, ByVal 0&
End Sub
回复
lihonggen0 2003-04-24
'关于标准下拉框的
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
Const CB_SHOWDROPDOWN = &H14F
Const CB_GETDROPPEDWIDTH = &H15F
Const CB_SETDROPPEDWIDTH = &H160

'改变下拉框的宽度,NewWidth为新宽度,可用strtmp取得最长的下拉框中的字符串,NewWidth=TextWidth(strTmp) * cbo1.FontSize / 9
SendMessage cbo1.hwnd, CB_SETDROPPEDWIDTH, NewWidth, 0

'弹出下拉框
SendMessage cbo1.hwnd, CB_SHOWDROPDOWN, True, 0

回复
liberte 2003-04-24
sendkeys {F4}
回复
howel 2003-04-24
不成啊,兄弟。
回复
Kain 2003-04-24
Sendmessage combo1.hwnd,cb_showdropdown,true,byval 0&
回复
发帖
控件
创建于2007-09-28

1425

社区成员

VB 控件
申请成为版主
帖子事件
创建了帖子
2003-04-24 01:31
社区公告
暂无公告