Strange RaiseEvent Problem

M

Martin

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(ByVal 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.
 
R

rowe_newsgroups

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
 
M

Martin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top