Results 1 to 3 of 3

Thread: Combo Box Size

  1. #1

    Thread Starter
    Junior Member traze's Avatar
    Join Date
    Mar 2001
    Location
    Bradenton FL, USA
    Posts
    30

    Question

    Howdy Y'all,
    I'm trying to adjust the number of items displayed in a drop down combo box. Basically if I have a boat load of items and I would like to display more than default 8. Any lines?
    Merci.
    DMS
    ---"tip of the red hat to ya"

  2. #2
    Guest
    To increase the height of the dropdown box, try this code.


    Code:
    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 SetComboHeight(oComboBox As ComboBox, _
    lNewHeight As Long)
    
    Dim oldscalemode As Integer
    
    ' This procedure does not work with frames: you 
    ' cannot set the ScaleMode to vbPixels, because 
    ' the frame does not have a ScaleMode Property. 
    ' To get round this, you could set the parent control
    ' to be the form while you run this procedure.
    
    If TypeOf oComboBox.Parent Is Frame Then Exit Sub
    
    ' Change the ScaleMode on the parent to Pixels.
    oldscalemode = oComboBox.Parent.ScaleMode
    oComboBox.Parent.ScaleMode = vbPixels
    
    ' Resize the combo box window.
    MoveWindow oComboBox.hwnd, oComboBox.Left, _
    oComboBox.Top, oComboBox.Width, lNewHeight, 1
    
    ' Replace the old ScaleMode
    oComboBox.Parent.ScaleMode = oldscalemode
    End Sub
    
    
    Usage
    
    
    Private Sub Form_Load()
        Call SetComboHeight(Combo1, 1450)
    End Sub

  3. #3

    Thread Starter
    Junior Member traze's Avatar
    Join Date
    Mar 2001
    Location
    Bradenton FL, USA
    Posts
    30

    Thumbs up Beautiful

    Mr. Gates you have out-done yourself once again! thank you for the snidbit.
    DMS
    ---"tip of the red hat to ya"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width