PC Review


Reply
Thread Tools Rate Thread

ComboBox Dropdown not under control

 
 
OssieMac
Guest
Posts: n/a
 
      23rd Feb 2010

ComboBox on a Userform.

I am using the following code to display the dropdown list for a ComboBox
when the user enters the ComboBox. However, when the form opens, the dropdown
list for the first Combo box is towards the top left of the screen outside of
the Userform instead of under the ComboBox control on the Userform. This
occurs in both xl2002 and xl2007. If I reduce the size of the Excel window,
the dropdown can be completely off the Excel window also.

I can actually make a selection form the dropdown.

It is almost like the drop down list is positioned relative to the top left
of the screen instead of the userform.

Any help to fix this problem will be greatly appreciated.

Private Sub ComboBox1_Enter()
If Me.ComboBox1.ListCount > 0 Then
Me.ComboBox1.DropDown
End If
End Sub

--
Regards,

OssieMac
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      24th Feb 2010
I now have a workaround for this in the following code example. Just set the
focus to another control that does not have an Enter event and then set it
back to the first combo box.

I feel fairly sure that what is occurring is that the dropdown is being
displayed before the form is painted and hense Excel does not know where to
position it and it gets positioned relative to the screen Top and Left
instead of the Form Top and Left.

Still interested (just curiosity) if anyone has another explanation or
alternative workaround.

Private Sub UserForm_Activate()
Me.CommandButton1.SetFocus
Me.ComboBox1.SetFocus
End Sub

--
Regards,

OssieMac


"OssieMac" wrote:

>
> ComboBox on a Userform.
>
> I am using the following code to display the dropdown list for a ComboBox
> when the user enters the ComboBox. However, when the form opens, the dropdown
> list for the first Combo box is towards the top left of the screen outside of
> the Userform instead of under the ComboBox control on the Userform. This
> occurs in both xl2002 and xl2007. If I reduce the size of the Excel window,
> the dropdown can be completely off the Excel window also.
>
> I can actually make a selection form the dropdown.
>
> It is almost like the drop down list is positioned relative to the top left
> of the screen instead of the userform.
>
> Any help to fix this problem will be greatly appreciated.
>
> Private Sub ComboBox1_Enter()
> If Me.ComboBox1.ListCount > 0 Then
> Me.ComboBox1.DropDown
> End If
> End Sub
>
> --
> Regards,
>
> OssieMac

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable and enable dropdown combobox(Form Control) =?Utf-8?B?Vmlub2Q=?= Microsoft Excel Misc 0 6th Nov 2007 07:30 PM
DropDown control implementation like ComboBox without stealing focus from form? Özden Irmak Microsoft Dot NET Framework Forms 0 17th Nov 2005 05:17 PM
Re: Bug: Combobox.dropdown = True during Form.Load event handler causes listbox to be disabled, even though combobox is Enabled. Herfried K. Wagner [MVP] Microsoft Dot NET Framework Forms 0 12th Feb 2004 10:00 PM
Bug: Combobox.dropdown = True during Form.New() causes listbox to be disabled, even though combobox is Enabled. =?Utf-8?B?UmF0a2lsZXk=?= Microsoft Dot NET Framework Forms 1 12th Feb 2004 09:58 PM
How to control height and location of custom dropdown combobox saragwyn Microsoft C# .NET 0 1st Aug 2003 07:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.