comboListBox 的下拉长度如何指定?
如我想点击下一次拉出50条记录,默认的太少了。

解决方案 »

  1.   

    好像可以用API函数SendMessage 发送消息改变,。。
      

  2.   

    comboListBox好象不可以修改。最多下拉显示10条吧?(大概是,记不清了)用第三方控件吧。要不就做个LISTBOX+COMBOLISTBOX
      

  3.   

    VB.NET可以设
    MaxDropDownItems属性
      

  4.   

    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 Form_Load()
        Dim i As Integer
        For i = 1 To 50
            Combo1.AddItem i
        Next i
        Call SetComboHeight(Combo1, 667)
    End Sub
      

  5.   

    VBDN(王水云) ,好啊!为什么frame容器不行?
      

  6.   

    用SendMessage吧:Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const CB_SETITEMHEIGHT = &H153
    Private Sub Form_Load()
        dim lngHeight as Long    '你要设置的高度,Pixel(像素)单位
        lngHeight=5000
        Call SendMessageA(Combo1.hwnd, CB_SETITEMHEIGHT, 0, lngHeight)
    End Sub
      

  7.   

    Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const CB_SETITEMHEIGHT = &H153
    Private Sub Form_Load()
        dim lngHeight as Long    '你要设置的高度,Pixel(像素)单位
        lngHeight=5000
        Call SendMessageA(Combo1.hwnd, CB_SETITEMHEIGHT, 0, lngHeight)
    End Sub
    试验无效果
      

  8.   

    多谢!刚找了个老外的解决方法:Public Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" _
    (ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As LongPublic Declare Function GetWindowRect Lib "user32" _
    (ByVal hWnd As Long, _
    lpRect As RECT) As LongPublic Declare Function ScreenToClient Lib "user32" _
    (ByVal hWnd As Long, _
    lpPoint As POINTAPI) As LongPublic 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 Const WM_SETREDRAW = &HB' Combo Box messages
    Private Const CB_GETEDITSEL = &H140
    Private Const CB_LIMITTEXT = &H141
    Private Const CB_SETEDITSEL = &H142
    Private Const CB_ADDSTRING = &H143
    Private Const CB_DELETESTRING = &H144
    Private Const CB_DIR = &H145
    Private Const CB_GETCOUNT = &H146
    Private Const CB_GETCURSEL = &H147
    Private Const CB_GETLBTEXT = &H148
    Private Const CB_GETLBTEXTLEN = &H149
    Private Const CB_INSERTSTRING = &H14A
    Private Const CB_RESETCONTENT = &H14B
    Private Const CB_FINDSTRING = &H14C
    Private Const CB_SELECTSTRING = &H14D
    Private Const CB_SETCURSEL = &H14E
    Private Const CB_SHOWDROPDOWN = &H14F
    Private Const CB_GETITEMDATA = &H150
    Private Const CB_SETITEMDATA = &H151
    Private Const CB_GETDROPPEDCONTROLRECT = &H152
    Private Const CB_SETITEMHEIGHT = &H153
    Private Const CB_GETITEMHEIGHT = &H154
    Private Const CB_SETEXTENDEDUI = &H155
    Private Const CB_GETEXTENDEDUI = &H156
    Private Const CB_GETDROPPEDSTATE = &H157
    Private Const CB_FINDSTRINGEXACT = &H158
    Private Const CB_SETLOCALE = &H159
    Private Const CB_GETLOCALE = &H15A
    Private Const CB_MSGMAX = &H15BPrivate Type POINTAPI
    x As Long
    y As Long
    End TypePrivate Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End TypePublic Sub ComboLines(ComboForm As Form, _
    ComboControl As Control, iLines As Integer)' Sets the number of lines displayed in the combo box
    ' drop-down list.' Pass -1 for iLines to set equal to number of items
    ' in the combobox.Dim pt As POINTAPI
    Dim rc As RECT
    Dim newHeight As Long
    Dim oldScaleMode As Long
    Dim oldTop As Long
    Dim oldLeft As Long
    Dim oldWidth As Long
    Dim itemHeight As LongIf iLines = -1 Then
    iLines = ComboControl.ListCount
    End IfoldTop = ComboControl.Top
    oldLeft = ComboControl.Left
    oldWidth = ComboControl.Width
    oldScaleMode = ComboForm.ScaleMode
    ComboForm.ScaleMode = vbPixels
    itemHeight = SendMessage(ComboControl.hWnd, _
    CB_GETITEMHEIGHT, 0, 0)
    newHeight = itemHeight * (iLines + 2)'Get the co-ordinates of the combo box
    'relative to the screen
    Call GetWindowRect(ComboControl.hWnd, rc)
    pt.x = rc.Left
    pt.y = rc.Top'Then translate into co-ordinates
    'relative to the form.
    Call ScreenToClient(ComboForm.hWnd, pt)'Using the values returned and set above,
    'call MoveWindow to reposition the combo box
    Call MoveWindow(ComboControl.hWnd, pt.x, pt.y, _
    ComboControl.Width, newHeight, True)'restore the original form scalemode
    'before leaving
    ComboForm.ScaleMode = oldScaleMode
    ComboControl.Top = oldTop
    ComboControl.Left = oldLeft
    ComboControl.Width = oldWidthEnd Sub