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

Invoking a PictureBox click ?

P: n/a
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.
Feb 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <zo*****@sify.com> wrote in message
news:Oz**************@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.

Feb 15 '06 #2

P: n/a
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.

"Stephany Young" <noone@localhost> wrote in message
news:OZ*************@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" <zo*****@sify.com> wrote in message
news:Oz**************@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.


Feb 15 '06 #3

P: n/a
"Stephany Young" <noone@localhost> schrieb:
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)


Avoid doing that! Instead, call 'PicBox_Click(Me.PixBox, EventArgs.Empty)'
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/>

Feb 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.