|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strange RaiseEvent ProblemI'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. Never mind, I have figured it out at last. Phew!
Show quoteHide quote "Martin" <@ntlworld.com> wrote in message news:AvEih.14871$Qa6.6886@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(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. > > Never mind, I have figured it out at last. Phew! Care to tell us? It's considered common courtesy to share you'resolution, in case someone else has a similar problem. Thanks, Seth Rowe Martin wrote: Show quoteHide quote > Never mind, I have figured it out at last. Phew! > > > "Martin" <@ntlworld.com> wrote in message > news:AvEih.14871$Qa6.6886@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(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. > > 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. Show quoteHide quote "rowe_newsgroups" <rowe_em***@yahoo.com> wrote in message news:1166753008.457403.37910@42g2000cwt.googlegroups.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.com> wrote in message >> news:AvEih.14871$Qa6.6886@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(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. >> > >
cut, copy, and paste
Reservation algorithm Multithreading with DirectoryServices pseudo spin-lock design help DirectoryServices Cast Error? can send data to sql 2005, can not read data from sql 2005 with vb Stopping Windows Service with Thread What Happened To F5 regex editor Console Application - run in hidden mode |
|||||||||||||||||||||||