PC Review


Reply
Thread Tools Rate Thread

ComboBox.Clear method calling ComboBox_Change event?

 
 
=?Utf-8?B?Q2xheW1hbg==?=
Guest
Posts: n/a
 
      1st Aug 2007
I need to clear out a ComboBox in order to prep it for later use. At the
current time, it has 200 entries. Eventually it will have over 2000. Removing
each item individually is not a desirable option. It takes a while to load
it. I'd hate for it to take that long to unload.

Problem is, when I execute ComboBox.Clear, it appears to call the
ComboBox_Change() event. Since there is nothing in the ComboBox, it calls the
error handler that checks for unknown entries (ie: typing your own data in
the BomboBox).

Is there a way to execute the .Clear method without calling the _Change()
event?
--
Adios,
Clay Harryman
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      1st Aug 2007
If you don't want users to be able to type in values that are not in the
combo box list, you can set the combo box style to frmStyleDropDownList.

When you clear the combo box list and the combo box currently has a selected
value, the Change event will fire. To avoid executing your code in the
change event, maybe you can exit out of the sub if the combo box has no value
selected. For example:

Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then Exit Sub

'put your code below
End Sub


--
Hope that helps.

Vergel Adriano


"Clayman" wrote:

> I need to clear out a ComboBox in order to prep it for later use. At the
> current time, it has 200 entries. Eventually it will have over 2000. Removing
> each item individually is not a desirable option. It takes a while to load
> it. I'd hate for it to take that long to unload.
>
> Problem is, when I execute ComboBox.Clear, it appears to call the
> ComboBox_Change() event. Since there is nothing in the ComboBox, it calls the
> error handler that checks for unknown entries (ie: typing your own data in
> the BomboBox).
>
> Is there a way to execute the .Clear method without calling the _Change()
> event?
> --
> Adios,
> Clay Harryman

 
Reply With Quote
 
=?Utf-8?B?Q2xheW1hbg==?=
Guest
Posts: n/a
 
      1st Aug 2007
The code sample will work well.

I was afraid to try "frmStyleDropDownList", thinking it would force the
users to click and scroll through up to 2000 items. But it worked quite well!

Thank you!
--
Adios,
Clay Harryman


"Vergel Adriano" wrote:

> If you don't want users to be able to type in values that are not in the
> combo box list, you can set the combo box style to frmStyleDropDownList.
>
> When you clear the combo box list and the combo box currently has a selected
> value, the Change event will fire. To avoid executing your code in the
> change event, maybe you can exit out of the sub if the combo box has no value
> selected. For example:
>
> Private Sub ComboBox1_Change()
> If ComboBox1.ListIndex = -1 Then Exit Sub
>
> 'put your code below
> End Sub
>
>
> --
> Hope that helps.
>
> Vergel Adriano
>
>
> "Clayman" wrote:
>
> > I need to clear out a ComboBox in order to prep it for later use. At the
> > current time, it has 200 entries. Eventually it will have over 2000. Removing
> > each item individually is not a desirable option. It takes a while to load
> > it. I'd hate for it to take that long to unload.
> >
> > Problem is, when I execute ComboBox.Clear, it appears to call the
> > ComboBox_Change() event. Since there is nothing in the ComboBox, it calls the
> > error handler that checks for unknown entries (ie: typing your own data in
> > the BomboBox).
> >
> > Is there a way to execute the .Clear method without calling the _Change()
> > event?
> > --
> > Adios,
> > Clay Harryman

 
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
Combobox_change event problem =?Utf-8?B?U2hhd24gRy4=?= Microsoft Excel Programming 2 18th Aug 2005 01:37 PM
worksheet.combobox.clear method not workable ? Marek Microsoft Excel Programming 1 4th Sep 2004 02:17 PM
worksheet.combobox.clear method not workable ? Marek Microsoft Excel Programming 0 4th Sep 2004 11:42 AM
problem with direcly calling combobox event s Domadia via .NET 247 Microsoft Dot NET Framework Forms 1 15th May 2004 07:22 AM
calling a method associated to an event Abdessamad Belangour Microsoft C# .NET 1 9th Dec 2003 03:39 PM


Features
 

Advertising
 

Newsgroups
 


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