Link to home
Start Free TrialLog in
Avatar of ram_paravastu
ram_paravastu

asked on

Increasing width of dropdown combo

How can i increase the width of the dropdown combo box ???

As soon as the user clicks on the combo box, the width of the combo should remain as is, but the drop down width should increase more than the width of the combo box.

Ram
Avatar of hangman
hangman

You can't, but what you could do is to design your own ActiveX control. That way you have full control over the appearance and function. A basic microsoft control cannot be customised to have new attributes  
Hi, ram_paravastu.

#Try This
You might want to use a combobox from the "Microsoft Forms 2.0 Object Library".  Use the ListWidth property to increase the width of the dropdown list portion.

Bye. -e2
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Assisting Ameba:

You might want to revise your example so it takes into account the fact that the ScaleMode of the Form may be unknown.

I think you were trying to get it to double the width of the dropdown list. Am I right?


Instead of:

   newwidth = 2 * Combo1.Width / 15 ' new width in pixels


Try:
   With Me
      NewWidth = 2 * .ScaleX(Combo1.Width, .ScaleMode, vbPixels)
   End With

ScaleX() coverts the X measurement from one ScaleMode to another. For example, twips to pixels. ScaleY does the same except for vertical measurement.

The syntax:

   ScaleX(<measurement>, <from scale>, <to scale>)


An alternative is to temporarily change the form's ScaleMode. For example:

Dim PrevMode As Integer

With Me
   PrevMode = .ScaleMode
   .ScaleMode = vbPixels
   NewWidth = 2 * Combo1.Width
   .ScaleMode = PrevMode
End With

Just some food for thought. :-)

-Dennis Borg
DennisBorg,
>I think you were trying to get it to double the width of the dropdown list. Am I right?

No, that was quick way to do what was asked:
>"the drop down width should increase more than the width of the combo box"

I cannot say it will produce double width, because not all systems have 'Screen.TwipsPerPixelX=15'
(e.g. if he has 'Large Fonts' in his screen properties, Screen.TwipsPerPixelX will be 12)

I assumed ram_paravastu knows how to convert twips<->pixels.

In case he did not know, he can certainly use your article / explanation.
Avatar of ram_paravastu

ASKER

Thanks