?
Solved

Drop-down List Combobox

Posted on 2000-02-14
5
Medium Priority
?
173 Views
Last Modified: 2010-05-02
Howdy.

I'm writing a program with many small forms that have large numbers of drop-down list comboboxes.  To save space on the forms, each combo box is rather small.  However, the items in the list are long, and get cut off.

Is there any way to expand the list to be the size of the longest item when it drops down, or to expand the control itself before the list drops, then put it back at the original size after the user makes their selection?

I'd rather not use a scrollbar, if at all possible.

Thanks.
0
Comment
Question by:aerelorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2519994
Something like this..

'Add 1 ComboBox to your form.
'Insert the following code to your form:

Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const CB_SETDROPPEDWIDTH = &H160

Private Sub Form_Load()
'Replace the '190' below with your desirable ComboBox dropdown width.
r = SendMessageLong(Combo1.hwnd, CB_SETDROPPEDWIDTH, 190, 0)
End Sub
0
 

Expert Comment

by:ramaswamy_ravi
ID: 2519997
Hi,

One easy way is to expand the width in the GotFocus event and reduce the width to the original size in the LostFocus event.

I think, there are also API calls to determine if the combobox is dropped-down or closed. I will later look into it and see if there is one.


The other solution is you can use 3rd party controls, where they treat the text area and the drop-down area as two different items. You can set the column width of the drop-down area and the text area at design time and not worry about it in the code. This is changing the free way entirely.

Please let me know, if this works for you.

Ravi

0
 

Author Comment

by:aerelorn
ID: 2520676
Thanks Ruchi, works perfectly.  Please repost as an answer.
0
 
LVL 9

Accepted Solution

by:
Ruchi earned 400 total points
ID: 2520750
Thanks, aerelorn.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question