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

Handling events

P: n/a
I have an object that I want to have a PictureBox as a
member of, and I want to be able handle the on click event
for that member PictureBox. How do I do it?

Right now, the PictureBox is declared:

Friend WithEvents f_PictureBox As
System.Windows.Forms.PictureBox

Private Sub PictureBox_Clicked(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
f_PictureBox.Click

But it doesn't except the last f_PictureBox.Click as valid.

Help
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
* "Sean" <an*******@discussions.microsoft.com> scripsit:
I have an object that I want to have a PictureBox as a
member of, and I want to be able handle the on click event
for that member PictureBox. How do I do it?

Right now, the PictureBox is declared:

Friend WithEvents f_PictureBox As
System.Windows.Forms.PictureBox

Private Sub PictureBox_Clicked(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
f_PictureBox.Click

But it doesn't except the last f_PictureBox.Click as valid.


Works perfectly for me. Do you get a compiler error or a runtime error?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
That sub declaration looks right to me assuming you actually have a
PictureBox on your form by that same name and that you're not just declaring
the variable alone.

Any more info you can provide?

Blake

"Sean" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I have an object that I want to have a PictureBox as a
member of, and I want to be able handle the on click event
for that member PictureBox. How do I do it?

Right now, the PictureBox is declared:

Friend WithEvents f_PictureBox As
System.Windows.Forms.PictureBox

Private Sub PictureBox_Clicked(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
f_PictureBox.Click

But it doesn't except the last f_PictureBox.Click as valid.

Help

Nov 20 '05 #3

P: n/a
Well, it is not form, it is a class, and I am passing the
PictureBox in as part of the constructor. I want whatever
PictureBox I assign to the object to be handled by the
event. Thanks.

Public Sub New(ByVal PB as PictureBox)

f_PictureBox = PB

End Sub

-----Original Message-----
That sub declaration looks right to me assuming you actually have aPictureBox on your form by that same name and that you're not just declaringthe variable alone.

Any more info you can provide?

Blake

"Sean" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
I have an object that I want to have a PictureBox as a
member of, and I want to be able handle the on click event for that member PictureBox. How do I do it?

Right now, the PictureBox is declared:

Friend WithEvents f_PictureBox As
System.Windows.Forms.PictureBox

Private Sub PictureBox_Clicked(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
f_PictureBox.Click

But it doesn't except the last f_PictureBox.Click as valid.
Help

.

Nov 20 '05 #4

P: n/a
Compiler...comes up underlined as an error.
-----Original Message-----
* "Sean" <an*******@discussions.microsoft.com> scripsit:
I have an object that I want to have a PictureBox as a
member of, and I want to be able handle the on click event for that member PictureBox. How do I do it?

Right now, the PictureBox is declared:

Friend WithEvents f_PictureBox As
System.Windows.Forms.PictureBox

Private Sub PictureBox_Clicked(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
f_PictureBox.Click

But it doesn't except the last f_PictureBox.Click as
valid.
Works perfectly for me. Do you get a compiler error or a runtime error?
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #5

P: n/a
* "Sean" <an*******@discussions.microsoft.com> scripsit:
Compiler...comes up underlined as an error.


Error message?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.