如何使组合框下接列表中的项目多于8个呢?默认只能显示8项。但是如何拉长些呢?
如何使组合框下接列表中的项目多于8个呢?默认只能显示8项。但是如何拉长些呢?
----------
找了半天,也没找到,以前好象看到过,要通过api函数实现,可是如何做呢?
[解决办法]
Const CB_GETITEMHEIGHT = &H154
Const CB_SETITEMHEIGHT = &H153
Const CB_SHOWDROPDOWN = &H14F
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 MoveWindow Lib "user32 " (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Form_Load()
Dim i As Long
For i = 1 To 50
Combo1.AddItem Format(i, "00000 ")
Next i
Combo1.ListIndex = 0
Dim lngCmbLineHeiht As Long
Dim lngCountLine As Long
Me.ScaleMode = vbPixels
With Combo1
lngCmbLineHeiht = SendMessage(.hwnd, CB_GETITEMHEIGHT, 0, ByVal 0)
'设定下拉共有几行
lngCountLine = 25 '行
MoveWindow .hwnd, .Left, .Top, .Width, lngCmbLineHeiht * (lngCountLine + 2), 1
End With
End Sub