Results 1 to 6 of 6

Thread: Combo Box

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    OK if I have a combo box and then contents of that combo box are filled by a DB, and when the contents are filled and you click on the combo box at run time the combo box cuts off anything that is wider than itself. Is there a way without widening the combo box that I could have the combo boxes' white part (You know when you click on it the contenst have a white background) automatically adjst to the size of the widest line in the combo box?

  2. #2
    Guest
    You mean, set the dropdown width of the combobox?

    Change the Public to Private if you want to use in the form declarations.

    Code:
    Public Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" (ByVal hwnd As Long, _
    ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Long) As Long
    
    Public Const CB_SETDROPPEDWIDTH = &H160
    
    Public Sub SetComboWidth(oComboBox As ComboBox, _
    lWidth As Long)
    
    ' lWidth is in pixels
    
    SendMessage oComboBox.hwnd, CB_SETDROPPEDWIDTH, lWidth, 0
    
    End Sub

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    No, the textwindow of the combo box is part of the combo box and you cannot widen it without widening the combo box itself.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    So would I then call the function?

  5. #5
    Guest

    Code Above

    Code:
    Usage
    
    'Call SetComboWidth(Combobox, width)
    Call SetComboWidth(Combo1, 500)
    And it will make the white part bigger, but keep the combobox the same size.

    This, therefore, proves HeSaidJoe wrong, who perhaps, tried to prove me wrong at first.

    In conclusion, I am right! I am always right!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Thanks, you are the man!

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