|
-
Feb 6th, 2009, 10:28 AM
#1
Thread Starter
Lively Member
ObjectEvent not firing, please help!
Hi all!
I built a usercontrol (JaNee), which fires an event called "Changed" when the optionbutton it contains is clicked.
The control is added to a parent usercontrol at runtime using Controls.add, like this:
Code:
Private WithEvents m_Ctl As VBControlExtender
...
Set m_Ctl = Controls.Add("MyControls.JaNee", "jnValue")
m_Ctl.Visible = True
I use the following to catch the event:
Code:
Private Sub m_Ctl_ObjectEvent(Info As EventInfo)
If Info.Name = "Changed" Then
MsgBox "Hello World!"
End If
End Sub
This works fine for other usercontrols I've built, but for some particular reason, the ObjectEvent is not fired for this usercontrol.
Any ideas guys? There has to be a logical explanation.
Please be kind enough to RATE a helpful post. 
-
Feb 7th, 2009, 06:51 PM
#2
Re: ObjectEvent not firing, please help!
This is going to sound like a couple of stupid questions.
1. Are sure the control loaded? Have you checked with a statement similar to:
If m_Ctl Is Nothing Then MsgBox "Failed to load JaNee"
2. Are you sure the option button is firing the event? Is there any code in the option button's click event that is being tested and doesn't fire the event for some cases?
3. Is the parent usercontrol & the JaNee controls enabled?
If you simply do a Debug.Print Info.Name, do you get other events from the dynamically loaded usercontrol?
Last edited by LaVolpe; Feb 7th, 2009 at 06:56 PM.
-
Feb 9th, 2009, 05:44 AM
#3
Thread Starter
Lively Member
Re: ObjectEvent not firing, please help!
I do not regard your questions stupid, so here's the answers:
1. Are sure the control loaded?
Yes, the control is visible.
2. Are you sure the option button is firing the event?
Yes, stepping through the code it executes the RaiseEvent statement, but the Changed event is not captured by the ObjectEvent handler.
3. Is the parent usercontrol & the JaNee controls enabled?
Yes, all enabled properties are set to True.
4. If you simply do a Debug.Print Info.Name, do you get other events from the dynamically loaded usercontrol?
No, the "Changed" event is the only one event it fires.
Thanks for thinking along. Any more suggestions?
Please be kind enough to RATE a helpful post. 
-
Feb 9th, 2009, 08:31 AM
#4
Thread Starter
Lively Member
Re: ObjectEvent not firing, please help!
I added a new usercontrol which raises "Changed" when clicked.
And as before the event is raised, but not handled by it's parent.
I compared the usercontrol's properties to one that does work, but they are an exact match. Therefor, I am beginning to think it has something to do with the project properties. Alas, no differences found there either.
As an old Hobbit would say: Confusticate and bebother VB!
Please be kind enough to RATE a helpful post. 
-
Feb 9th, 2009, 08:50 AM
#5
Re: ObjectEvent not firing, please help!
I tried to play along. I created a uc (uc#1) that had a couple of option buttons that raised a change event & compiled it. In IDE, I added a new usercontrol (uc#2) that dynamically loaded uc#1, using Controls.Add(...). When the option button was clicked, I did get the event in uc#2. Last dumb question: SP6 installed? I am running out of dumb questions & good ideas.
-
Feb 9th, 2009, 09:16 AM
#6
Thread Starter
Lively Member
Re: ObjectEvent not firing, please help!
SP6 is installed allright.
I added the usercontrol that fires the event to the parent control's project and it works fine now.
But off course, this not a fancy solution. Maybe if I reach the brilliant zone in the future, which I doubt, I will add the solution to this thread. Unless anyone else figures this thing out.
Thanks for your help. I'll add one to your rep.
Please be kind enough to RATE a helpful post. 
-
Feb 9th, 2009, 10:22 AM
#7
Re: ObjectEvent not firing, please help!
If I understand you correctly the parent.child relationship looks like this:
FormX.UserCtrl1.JaNee
UserCtrl1 does get JaNee's events? If so, you want JaNee to send the event directly to the form? I don't think that is doable. JaNee would trigger events to UserCtrl1 and UserCtrl1 may need to forward/propogate those events to FormX
The child parent relationship described above is what I used to try to replicate the problem. I may not have replicated the scenario correctly?
-
Feb 9th, 2009, 11:05 AM
#8
Thread Starter
Lively Member
Re: ObjectEvent not firing, please help!
Nope. Just plain and simple UserCtrl1 handles JaNee's events.
The JaNee is loaded runtime.
Please be kind enough to RATE a helpful post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|