CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2000
    Posts
    40

    Combo box problems

    Question 1: I have a drop-down combo box which can only diplay partial items in the list, because a scroll bar is added automatically when you have more than 5 items in the list. Is there a way to make the list longer, so it can display complete item list?

    Question 2: Is there a way to let items in combo box list align from right to left?

    Thanks for help.




  2. #2

    Re: Combo box problems

    q1: sorry no
    q2: sorry no

    hi,brt

    ps U can try to find for some API... but I have some dubt for your requests...

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  3. #3
    Join Date
    Aug 2001
    Posts
    26

    Re: Combo box problems

    CANNOT CHANGE THE HEIGHT OF LIST FOR A COMBO BOX.
    CANNOT ALLIGN THE TEXT IN LIST FROM RIGHT TO LEFT.
    FOR UR REQUIREMENT I THINK YOU USE THE LIST BOX


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Combo box problems

    Here the code how to change the combo width

    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 Command1_Click()
    Dim ret
    Dim iScaleMode
    iScaleMode = Combo1.Parent.ScaleMode
    Combo1.Parent.ScaleMode = vbPixels
    ret = MoveWindow(Combo1.hwnd, Combo1.Left, Combo1.Top, Combo1.Width, 1450, 1)
    Combo1.Parent.ScaleMode = iScaleMode
    End Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Combo box problems

    Sorry that was height not width

    For width use the following codr

    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
    Const CB_SETDROPPEDWIDTH = &H160

    ' Set the width of the list area of a ComboBox (in pixels)

    Sub SetComboDropDownWidth(ComboBox As ComboBox, ByVal lWidth As Long)
    Call SendMessageLong(ComboBox.hWnd, CB_SETDROPPEDWIDTH, lWidth, ByVal 0&)
    End Sub

    For example, you can use the above reusable routine to set a ComboBox's drop down list width to 200 pixels
    using the following line of code:

    SetComboDropDownWidth Combo1, 200



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  6. #6
    Join Date
    Sep 2000
    Posts
    40

    Re: Combo box problems

    It works. Thanks.



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

Featured