Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox dropdown height 1

Status
Not open for further replies.

lilboi

Programmer
Dec 22, 2003
146
CA
Hey guys,

Is it possible to control the size of the dropdown menu? I think .net has the dropdownheight option but I'm not sure if VB has that capability.

I want to increase the height because the list could have more than 100 options and scrolling down through all of it may be a bit tiresome.

Thanks!
 
VB does not have that option directly, but it can be done through the API

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

Public Sub SetComboHeight(ByRef oCombo As ComboBox, lHeight As Long)
Dim iOrigScaleMode As Integer
Dim lReturn As Long
Dim bRepaint As Long
bRepaint = 1&
With oCombo
'cache the parent's current scale mode.
iOrigScaleMode = .Parent.ScaleMode
'change the parent's scale mode to Pixels.
.Parent.ScaleMode = vbPixels

'Position combo, keeping it's current Left, Top, and Width positions, but changing the height.
lReturn = MoveWindow(.hwnd, .Left, .Top, .Width, lHeight, bRepaint)

'restore the parent's scale mode to the original value.
.Parent.ScaleMode = iOrigScaleMode
End With
End Sub
 
awesome! hehe it worked! thank you so much!
 
Hey strongm,

Do the dropdown lists have to be in a certain format? It works for me on one of the dropdown list but when I try to resize the others ones, it won't work. The dropdown list disappears instead. know what would cause that?

Thanks
 
Oh! What I noticed is the differenc between the comboxes that worked and the ones that doesn't is that the ones that doesn't are on a frame and picture box. I have to do this becuz I'm running the manifest.

The one that works properly is outside a frame....any inputs?
 
This is just example code, not a full solution for all scenarios. It should, however, illustrate what ti is that you need to do.

Now, the reason that it doesn't work on a combobox on in a frame is because a frame doesn't have a ScaleMode property. Don't know offhand why any in a pciture box would fail
 
ah ic ic. Most of my combo boxes are in a frame tho. hehe

Thanks tho!
 
That's fine, you just have to get the frame into pixel scale mode, which means you need to get the frame's parent into pixel scale mode (note that this is bacause we're trying to keep as much of this as possible in VB; if we were working with apure API solution we'd have fewer hoops to jump through)
 
awesome!! It worked when I changed the PictureBox into pixel scale mode. This is beyond my understanding. hehe But as long as it worked. Thanks so much!
 
And naturally we've discussed twips here in this forum. Check out thread222-455004 and thread222-749258
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top