-
May 10th, 2011, 12:41 PM
#1
Thread Starter
Member
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
-
May 10th, 2011, 04:19 PM
#2
Re: How to remove / hide dropdown arrow of a Combobox ?
Originally Posted by WeeBee
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.
-
May 11th, 2011, 11:58 AM
#3
Thread Starter
Member
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
-
May 11th, 2011, 12:09 PM
#4
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.
-
Jun 15th, 2011, 09:30 PM
#5
Thread Starter
Member
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:
Private Sub CutDropDbutton(Ctl As ComboBox) Dim rect As Long rect = CreateRectRgn(100 - Ctl.Width / Screen.TwipsPerPixelX, 0, Ctl.Width / Screen.TwipsPerPixelX - 18, Ctl.Height) SetWindowRgn Ctl.hwnd, rect, True DeleteObject rect 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"
----------------------------------------------------------------------------------------------------------------------------------------------------
-
Jun 15th, 2011, 11:41 PM
#6
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.
-
Jun 16th, 2011, 12:05 AM
#7
Thread Starter
Member
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"
----------------------------------------------------------------------------------------------------------------------------------------------------
-
Jun 16th, 2011, 12:25 AM
#8
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?
-
Jun 16th, 2011, 12:55 AM
#9
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|