By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

Strange RaiseEvent Problem

P: n/a
Hi all,

I'm having a problem when trying to raise an event in my custom control when
a toolstripbutton enable state changes. The problem is that although the
code to raise the event executes, my handler never see it.

This executes when the button enable state changes:-

Private Sub OnPrintToolStripButton_EnabledChanged(ByVal sender As Object,
ByVal e As System.EventArgs)Handles PrintToolStripButton.EnabledChanged
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This doesn't raise an event

When I step through the code, the raiseevent line executes but the debugger
doesn't jump to my handler.

If however, I raise the exact same event, but from a button click event,
then it works as expected and the event handler is run.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This raises the event ok

This is my event handler code:
Private Sub MyControl_PrintToolStripButton_EnabledChanged(ByVa l sender As
Object, ByVal e As System.EventArgs) Handles
MyControl.PrintToolStripButton_EnabledChanged
Me.Menu_Print.Enabled = MyControl.PrintToolStripButton.Enabled
End Sub

Has anyone encountered anything similar, or is able to point out my obvious
mistake?

Thanks for your time and kind regards,

Martin.
Dec 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Never mind, I have figured it out at last. Phew!
"Martin" <@ntlworld.comwrote in message
news:Av******************@newsfe6-gui.ntli.net...
Hi all,

I'm having a problem when trying to raise an event in my custom control
when a toolstripbutton enable state changes. The problem is that although
the code to raise the event executes, my handler never see it.

This executes when the button enable state changes:-

Private Sub OnPrintToolStripButton_EnabledChanged(ByVal sender As Object,
ByVal e As System.EventArgs)Handles PrintToolStripButton.EnabledChanged
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This doesn't raise an event

When I step through the code, the raiseevent line executes but the
debugger doesn't jump to my handler.

If however, I raise the exact same event, but from a button click event,
then it works as expected and the event handler is run.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This raises the event ok

This is my event handler code:
Private Sub MyControl_PrintToolStripButton_EnabledChanged(ByVa l sender As
Object, ByVal e As System.EventArgs) Handles
MyControl.PrintToolStripButton_EnabledChanged
Me.Menu_Print.Enabled = MyControl.PrintToolStripButton.Enabled
End Sub

Has anyone encountered anything similar, or is able to point out my
obvious mistake?

Thanks for your time and kind regards,

Martin.

Dec 22 '06 #2

P: n/a
Never mind, I have figured it out at last. Phew!

Care to tell us? It's considered common courtesy to share you're
solution, in case someone else has a similar problem.

Thanks,

Seth Rowe
Martin wrote:
Never mind, I have figured it out at last. Phew!
"Martin" <@ntlworld.comwrote in message
news:Av******************@newsfe6-gui.ntli.net...
Hi all,

I'm having a problem when trying to raise an event in my custom control
when a toolstripbutton enable state changes. The problem is that although
the code to raise the event executes, my handler never see it.

This executes when the button enable state changes:-

Private Sub OnPrintToolStripButton_EnabledChanged(ByVal sender As Object,
ByVal e As System.EventArgs)Handles PrintToolStripButton.EnabledChanged
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This doesn't raise an event

When I step through the code, the raiseevent line executes but the
debugger doesn't jump to my handler.

If however, I raise the exact same event, but from a button click event,
then it works as expected and the event handler is run.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This raises the event ok

This is my event handler code:
Private Sub MyControl_PrintToolStripButton_EnabledChanged(ByVa l sender As
Object, ByVal e As System.EventArgs) Handles
MyControl.PrintToolStripButton_EnabledChanged
Me.Menu_Print.Enabled = MyControl.PrintToolStripButton.Enabled
End Sub

Has anyone encountered anything similar, or is able to point out my
obvious mistake?

Thanks for your time and kind regards,

Martin.
Dec 22 '06 #3

P: n/a
Well, it turned out to be a mistake in my code, so the solution was 'not to
make mistakes'. A little embarrassing really! lol

Regards,

Martin.

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@42g2000cwt.googlegrou ps.com...
>Never mind, I have figured it out at last. Phew!

Care to tell us? It's considered common courtesy to share you're
solution, in case someone else has a similar problem.

Thanks,

Seth Rowe
Martin wrote:
>Never mind, I have figured it out at last. Phew!
"Martin" <@ntlworld.comwrote in message
news:Av******************@newsfe6-gui.ntli.net...
Hi all,

I'm having a problem when trying to raise an event in my custom control
when a toolstripbutton enable state changes. The problem is that
although
the code to raise the event executes, my handler never see it.

This executes when the button enable state changes:-

Private Sub OnPrintToolStripButton_EnabledChanged(ByVal sender As
Object,
ByVal e As System.EventArgs)Handles PrintToolStripButton.EnabledChanged
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This doesn't raise an event

When I step through the code, the raiseevent line executes but the
debugger doesn't jump to my handler.

If however, I raise the exact same event, but from a button click
event,
then it works as expected and the event handler is run.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
RaiseEvent PrintToolStripButton_EnabledChanged(sender, e)
End Sub ' This raises the event ok

This is my event handler code:
Private Sub MyControl_PrintToolStripButton_EnabledChanged(ByVa l sender
As
Object, ByVal e As System.EventArgs) Handles
MyControl.PrintToolStripButton_EnabledChanged
Me.Menu_Print.Enabled = MyControl.PrintToolStripButton.Enabled
End Sub

Has anyone encountered anything similar, or is able to point out my
obvious mistake?

Thanks for your time and kind regards,

Martin.

Dec 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.