ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm events (https://www.excelbanter.com/excel-programming/307452-userform-events.html)

R Avery

UserForm events
 
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.

Tom Ogilvy

UserForm events
 
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.

--
Regards,
Tom Ogilvy


"R Avery" wrote in message
...
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.




Harald Staff

UserForm events
 
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 Avery" skrev i melding
...
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.




R Avery

UserForm events
 
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?


Tom Ogilvy wrote:

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.


Tom Ogilvy

UserForm events
 
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.

--
Regards,
Tom Ogilvy


"R Avery" wrote in message
...
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?


Tom Ogilvy wrote:

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.




R Avery

UserForm events
 
Ok. I understand. Thanks a lot. I love this newsgroup.



Tom Ogilvy wrote:

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.



All times are GMT +1. The time now is 07:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com