UserForm events

R

R Avery

I have a form and a class that uses the form. I want to trap events for
a ListBox within the class. I have a MSForms.ListBox variable in the
class, which I set to be the listbox in the form. However, there are
fewer events that I can trap in the class than I could in the form
(there are fewer entries in the combobox containing the list of possible
events). Why? Is there anyway to change this?

In particular, the AfterUpdate, Enter, Exit and maybe some other events
are missing. The same thing happens with other controls, as well. Any
help would be appreciated.
 
T

Tom Ogilvy

those events belong to the control object - the container on the form that
holds the listbox. To the best of my knowledge, you can't manage those
events from a class.
 
H

Harald Staff

Hi

As far as I know, no. It's an annoying limitation. A workaround might be to
call a class' public sub from the control's own event, lik, in the userform

Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call MyObject.EvaluateMe
End Sub

HTH. Best wishes Harald
 
R

R Avery

Actually, not only cannot I trap those events, but when I set the
class's ListBox (or any other control that I have tested), it does not
seem to have all of the proper methods according to intellisense. For
example, it is missing the Top and Left properties. However, I can set
these despite not being in Intellisense.

Why? Is there anyway to fix this?
 
T

Tom Ogilvy

Again, if you look at the object browser, you will probably see those are
properties of the control object and not of the listbox itself - such as
rowsource as an example. When the listbox is on the worksheet, the property
is ListFillRange and is provided by the OLEObject. If you can set them,
then I don't see anything to fix. For the events, I am not aware of a fix.
 
Top