|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Invoking a PictureBox click ?The Click event handler of a button control can be invoked using the Button.PerformClick method. But I have a Picturebox, whose click event handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I could set up a Custom method and call that method instead, but it would require some recoding, so I was wondering if the Event can be raised directly. (I vaguely recall a way to do this, but it's evading me right now!) Private Sub PicBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PicBox.Click 'My code here. End Sub How do I call this method, or raise the Click event for the PictureBox ? Thanks in advance, Regards, Cerebrus. As long as the sender and e arguments are of no consequence to the piece of
magic contained in 'My code here., then you can simply call: PicBox_Click(Nothing, Nothing) A cleaner way to deal with it though, is to seperate the desired operation from the event handler: Private Sub PicBoxClickHandler() 'My code here. End sub The 'My code here. in PicBox_Click now becomes: PicBoxClickHandler() which can also be called quite cleanly from anywhere that can access the procedure. Show quoteHide quote "Cerebrus99" <zorg***@sify.com> wrote in message news:OzINTShMGHA.1424@TK2MSFTNGP12.phx.gbl... > Hi all, > > The Click event handler of a button control can be invoked using the > Button.PerformClick method. But I have a Picturebox, whose click event > handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I > could set up a Custom method and call that method instead, but it would > require some recoding, so I was wondering if the Event can be raised > directly. (I vaguely recall a way to do this, but it's evading me right > now!) > > Private Sub PicBox_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles PicBox.Click > 'My code here. > End Sub > > How do I call this method, or raise the Click event for the PictureBox ? > > Thanks in advance, > > Regards, > > Cerebrus. > > Hi Stephany,
Thanks for your prompt response. I tried PicBox_Click and it works fine. I was missing out something obvious and was trying to call PicBox.Click(nothing, nothing). Didn't realize that I should change it to PicBox_Click ! Thanks a lot. Regards, Cerebrus. Show quoteHide quote "Stephany Young" <noone@localhost> wrote in message news:OZEwfbhMGHA.720@TK2MSFTNGP14.phx.gbl... > As long as the sender and e arguments are of no consequence to the piece of > magic contained in 'My code here., then you can simply call: > > PicBox_Click(Nothing, Nothing) > > A cleaner way to deal with it though, is to seperate the desired operation > from the event handler: > > Private Sub PicBoxClickHandler() > 'My code here. > End sub > > The 'My code here. in PicBox_Click now becomes: > > PicBoxClickHandler() > > which can also be called quite cleanly from anywhere that can access the > procedure. > > > "Cerebrus99" <zorg***@sify.com> wrote in message > news:OzINTShMGHA.1424@TK2MSFTNGP12.phx.gbl... > > Hi all, > > > > The Click event handler of a button control can be invoked using the > > Button.PerformClick method. But I have a Picturebox, whose click event > > handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I > > could set up a Custom method and call that method instead, but it would > > require some recoding, so I was wondering if the Event can be raised > > directly. (I vaguely recall a way to do this, but it's evading me right > > now!) > > > > Private Sub PicBox_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles PicBox.Click > > 'My code here. > > End Sub > > > > How do I call this method, or raise the Click event for the PictureBox ? > > > > Thanks in advance, > > > > Regards, > > > > Cerebrus. > > > > > > "Stephany Young" <noone@localhost> schrieb: Avoid doing that! Instead, call 'PicBox_Click(Me.PixBox, EventArgs.Empty)' > As long as the sender and e arguments are of no consequence to the piece > of magic contained in 'My code here., then you can simply call: > > PicBox_Click(Nothing, Nothing) or, even better, use a separate procedure (as you already described). -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
beginner update excel ?
multiple threads updating same log file extending BackgroundWorker ProgressChangedEventArgs Random number problem Percentages Need to resize label height automatically. ThreadPool.QueueUserWorkItem listview checkbox column - toggle image console.write Noob Question - Best Control for a TV Guide? |
|||||||||||||||||||||||