1.在窗口增加一个command和一个combobox 2.把下面代码加入到form中 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 LongPublic Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long) Dim oldscalemode As Integer If TypeOf oComboBox.Parent Is Frame Then Exit Sub oldscalemode = oComboBox.Parent.ScaleMode oComboBox.Parent.ScaleMode = vbPixels MoveWindow oComboBox.hwnd, oComboBox.Left, _ oComboBox.Top, oComboBox.Width, lNewHeight, 1 oComboBox.Parent.ScaleMode = oldscalemode End Sub Private Sub Command1_Click() Call SetComboHeight(Combo1, 170) End Sub 注:170是代码pixels.
如果是frame 也可以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 LongPublic Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long) Dim oldscalemode As Integer 'If TypeOf oComboBox.Parent Is Frame Then Exit Sub oldscalemode = oComboBox.Parent.ScaleMode oComboBox.Parent.ScaleMode = vbPixels MoveWindow oComboBox.hwnd, oComboBox.Left, _ oComboBox.Top, oComboBox.Width, lNewHeight, 1 oComboBox.Parent.ScaleMode = oldscalemode End SubPrivate Sub Command1_Click() Call SetComboHeight(Combo1, 170) '设置回原来的 Combo1.Top = 480 Combo1.Left = 480 Combo1.Width = 2055
如果是.NET就好了,可以设置Combo的条数的~
2.把下面代码加入到form中
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 LongPublic Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long)
Dim oldscalemode As Integer
If TypeOf oComboBox.Parent Is Frame Then Exit Sub
oldscalemode = oComboBox.Parent.ScaleMode
oComboBox.Parent.ScaleMode = vbPixels
MoveWindow oComboBox.hwnd, oComboBox.Left, _
oComboBox.Top, oComboBox.Width, lNewHeight, 1
oComboBox.Parent.ScaleMode = oldscalemode
End Sub
Private Sub Command1_Click()
Call SetComboHeight(Combo1, 170)
End Sub
注:170是代码pixels.
(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 LongPublic Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long)
Dim oldscalemode As Integer
'If TypeOf oComboBox.Parent Is Frame Then Exit Sub
oldscalemode = oComboBox.Parent.ScaleMode
oComboBox.Parent.ScaleMode = vbPixels
MoveWindow oComboBox.hwnd, oComboBox.Left, _
oComboBox.Top, oComboBox.Width, lNewHeight, 1
oComboBox.Parent.ScaleMode = oldscalemode
End SubPrivate Sub Command1_Click()
Call SetComboHeight(Combo1, 170) '设置回原来的
Combo1.Top = 480
Combo1.Left = 480
Combo1.Width = 2055
End Sub