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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box 1

Status
Not open for further replies.

Vec

IS-IT--Management
Jan 29, 2002
418
0
0
US
How can I set Combo1 so that it auto sizes to the form during form load?

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
You can also move a control like so..

With Combo1
.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth
End With

You can't resize a combo height, but for a command button or other control you can add the height parameter to the code..

With Command1
.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight
End With

Or
With Command1
.Move 20, 100, 1000, 300
End With

Have fun & Thanks for the votes!
 
LPlates:
Thank you for all the great help. I will be making a couple more posts this evening, still working out a few details on my project, hope to see your input!

-------------------------------------------------------------------------
-------------------------------------------------------------------------

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
>You can't resize a combo height
However, it is possible with the MoveWindow API.
Drop this into a public module so it can be used by any ComboBox control.[blue]
Code:
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
[green]
Code:
        'cache the parent's current scale mode.
[blue]
Code:
        iOrigScaleMode = .Parent.ScaleMode
[green]
Code:
        'change the parent's scale mode to Pixels.
[blue]
Code:
        .Parent.ScaleMode = vbPixels
[green]
Code:
        'Position combo, keeping it's current Left, Top, and Width positions, but changing the height.
[blue]
Code:
        lReturn = MoveWindow(.hwnd, .Left, .Top, .Width, lHeight, bRepaint)
[green]
Code:
        'restore the parent's scale mode to the original value.
[blue]
Code:
        .Parent.ScaleMode = iOrigScaleMode
    End With
End Sub
[black]
Then, call it as follows (this example sets the height twice this size as the default size):

SetComboHeight Combo1, Combo1.Height * 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top