473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Handling events

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
5 886
* "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
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
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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marinos Christoforou | last post by:
Sorry if this has been asked before but as an inexperienced wanna-be C# programmer I wondering how to code classes to help build a standard Windows UI. For example to build a common toolbar. I...
2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
4
by: hillcountry74 | last post by:
Hi, I'm a newbie and trying to understand event handling in c#. I have understood handling events using delelgate objects. But not this method- "Event handling by overriding the virtual...
3
by: Ashok Kumar K | last post by:
Hi all, Where can I get some insight on using the __hook, __unhook, event_source and event_receiver for specifically COM events. The documentation given in MSDN is very minimal. I have the...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
9
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
2
by: Paul E. Orman | last post by:
I have a piece of VB code (.NET 1.1 - VB 2003) that loads data from a database through a timer. So the timer is setup and from it I call the procedure that loads the latest records from the...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
2
by: Jordan | last post by:
I need to handle UI events in a worker thread instead of the primary UI thread. In C#, is the normal UI event handling behavior to run in a context thread on the thread pool or are events always...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.