Results 1 to 9 of 9

Thread: How to remove / hide dropdown arrow of a Combobox ?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    35

    Question How to remove / hide dropdown arrow of a Combobox ?

    Is there any way to delete/hide the arrow of a combo box ? Any Api's?
    I need a combo box with ordinary combo features (Style-0 Dropdown combo) without drop down arrow...I don't want to use MS/Forms.20 combobox, has the same feature...

    Thanks

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How to remove / hide dropdown arrow of a Combobox ?

    Quote Originally Posted by WeeBee View Post
    Is there any way to delete/hide the arrow of a combo box ? Any Api's?
    I need a combo box with ordinary combo features (Style-0 Dropdown combo) without drop down arrow...I don't want to use MS/Forms.20 combobox, has the same feature...

    Thanks
    I don't know how if you can hide that button or not, if you can get the handle to that combo button then maybe using the ShowWindow API could hide it?

    Since no one else has replied yet, One way might be to put the combox inside a picbox, use API to get the size of the combos Edit box and re-size the picbox which is what I tried below.... taking for granted the 3D borders of the control are a certain size...

    Code:
    'note: paste a combobox inside a 3D picture box.
    Option Explicit
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    
    Private Sub Form_Load()
    
    ' Optional - Add some test items to combo (note: user can still use mousewheel to change values)
    Combo1.AddItem "A"
    Combo1.AddItem "B"
    Combo1.AddItem "C"
    Combo1.AddItem "D"
    
        Dim cbo_rect As RECT
        Dim cbo_edit As Long
        ' set form and picbox to pixel mode (otherwise will need to convert size values to Form/PicBox scalemodes)
        Me.ScaleMode = vbPixels
        Picture1.ScaleMode = vbPixels
        ' offset combobox inside picbox to hide the 3D borders
        Combo1.Move -2, -2
        ' get handle to combo "Edit" window
        cbo_edit = FindWindowEx(Combo1.hwnd, 0, "Edit", vbNullString)
        If cbo_edit = 0 Then
            MsgBox "combo box Edit window not found!"
        Else
            ' get size of combo edit box
            GetWindowRect cbo_edit, cbo_rect
            ' resize picbox to combo edit size (+ offset for borders?)
            Picture1.Width = (cbo_rect.Right - cbo_rect.Left) + 4
            Picture1.Height = (cbo_rect.Bottom - cbo_rect.Top) + 4
        End If
    End Sub
    Last edited by Edgemeal; May 10th, 2011 at 05:43 PM.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    35

    Re: How to remove / hide dropdown arrow of a Combobox ?

    Thanks man...Not the exact code i am looking for...but still the idea is very good...

    Thanks again

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to remove / hide dropdown arrow of a Combobox ?

    I have no idea why you want to do this, but you will need code like what Edgemeal posted or you can create your own dropdown control.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    35

    Re: How to remove / hide dropdown arrow of a Combobox ?

    Hack,

    I need it as input control overlayed on Flexgrid -

    What about this code...?

    vb Code:
    1. Private Sub CutDropDbutton(Ctl As ComboBox)
    2. Dim rect As Long
    3. rect = CreateRectRgn(100 - Ctl.Width / Screen.TwipsPerPixelX, 0, Ctl.Width / Screen.TwipsPerPixelX - 18, Ctl.Height)
    4. SetWindowRgn Ctl.hwnd, rect, True
    5. DeleteObject rect
    6. End Sub
    Last edited by WeeBee; Jun 15th, 2011 at 09:35 PM.
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    "Pasting somebody's Code or Link is easy; Spending some time and addressing the real issue & putting our own ideas and codes is difficult"
    ----------------------------------------------------------------------------------------------------------------------------------------------------

  6. #6
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: How to remove / hide dropdown arrow of a Combobox ?

    if u put the combo inside the picbox or frame so u can hide the arrow by reducing frame/picbox width.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  7. #7

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    35

    Re: How to remove / hide dropdown arrow of a Combobox ?

    Seenu...Thanks for your suggestion...

    Edgemeal already given a solid example of doing the same...but what i am thinking is, i need to put 5 combo box, means i have to put 5 picture box for nothing...
    Last edited by WeeBee; Jun 16th, 2011 at 12:17 AM.
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    "Pasting somebody's Code or Link is easy; Spending some time and addressing the real issue & putting our own ideas and codes is difficult"
    ----------------------------------------------------------------------------------------------------------------------------------------------------

  8. #8
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: How to remove / hide dropdown arrow of a Combobox ?

    I need a combo box with ordinary combo features (Style-0 Dropdown combo)
    why dont u try style =1 simple combo? is that not fine for u? if yes any reason?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  9. #9

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    35

    Re: How to remove / hide dropdown arrow of a Combobox ?

    Actually my idea is to avoid unnecessary mouse downs on the grid and my goal is to fill the grid quickly with keyboard without mouse clicks:
    At key down event of combo box: sendmessage will fire the combo dropdown
    At key press event of combo box: the combo will highlight the matching text from the drop down list

    Previously i used fm20 combo box and it is very good at it and got some extra capabilities than normal vb combo...fm20 has some issues with re-distribution that's why i stopped using it...

    style 1 simple combo is a combination of textbox + listbox - I don't want this
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    "Pasting somebody's Code or Link is easy; Spending some time and addressing the real issue & putting our own ideas and codes is difficult"
    ----------------------------------------------------------------------------------------------------------------------------------------------------

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