473,399 Members | 2,278 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,399 software developers and data experts.

Sharing common events

I am trying to share mouse events (click, up, down, move and the such) for
30 different label controls: Here is my code:

Dim myLabel as Label

Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown

myLabel = lblP1JoyUp

myLabelMouseDown()

End Sub

Public Sub myLabelMouseDown()

If e.Button = MouseButtons.Left Then

My code here

ElseIf e.Button = MouseButtons.Right Then

My code here

End If

End Sub
The problem is that it tells me "e" isn't declared. Am I missing something
with my handlers? I thought I had this working at one time with help from
Cor but can't find it no how.

Thanks,
John

Nov 21 '05 #1
4 1109
I seem to have found Cor's example and a post from Jay. I'll give it another
go.

John

"jcrouse" <me> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
I am trying to share mouse events (click, up, down, move and the such) for
30 different label controls: Here is my code:

Dim myLabel as Label

Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown

myLabel = lblP1JoyUp

myLabelMouseDown()

End Sub

Public Sub myLabelMouseDown()

If e.Button = MouseButtons.Left Then

My code here

ElseIf e.Button = MouseButtons.Right Then

My code here

End If

End Sub
The problem is that it tells me "e" isn't declared. Am I missing something
with my handlers? I thought I had this working at one time with help from
Cor but can't find it no how.

Thanks,
John


Nov 21 '05 #2
>
Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown

myLabel = lblP1JoyUp

myLabelMouseDown()
change this to: myLabelMouseDown(e)

End Sub
Public Sub myLabelMouseDown()
and this to: Public Sub myLabelMouseDown(ByVal e as
System.Windows.Forms.MouseEventArgs)

If e.Button = MouseButtons.Left Then

My code here

ElseIf e.Button = MouseButtons.Right Then

My code here

End If

End Sub
The problem is that it tells me "e" isn't declared.


That's exactly what that means. In the procedure myLabelMouseDown 'e' hasn't
been declared anywhere.
hope this helps..
Imran.
Nov 21 '05 #3
* "jcrouse" <me> scripsit:
I am trying to share mouse events (click, up, down, move and the such) for
30 different label controls: Here is my code:

Dim myLabel as Label

Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown

myLabel = lblP1JoyUp

myLabelMouseDown()

End Sub


Instead of adding one handler per control, add a common handler. To do
that, add all 30 controls to the 'Handles...' list at the procedure
head's end ('Handles Label1.MouseDown, Handles Label2.MouseDown, ...'),
or use 'AddHandler to add the common handler to all of the controls'
'MouseDown' event. Then you can check the event handler's 'sender'
parameter to see which control caused the event:

\\\
Dim SourceControl As Control = DirectCast(sender, Control)
....
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Got it resolved!

Thanks for your patience guys,
John
"jcrouse" <me> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
I am trying to share mouse events (click, up, down, move and the such) for
30 different label controls: Here is my code:

Dim myLabel as Label

Private Sub lblP1JoyUp_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lblP1JoyUp.MouseDown

myLabel = lblP1JoyUp

myLabelMouseDown()

End Sub

Public Sub myLabelMouseDown()

If e.Button = MouseButtons.Left Then

My code here

ElseIf e.Button = MouseButtons.Right Then

My code here

End If

End Sub
The problem is that it tells me "e" isn't declared. Am I missing something
with my handlers? I thought I had this working at one time with help from
Cor but can't find it no how.

Thanks,
John


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Neve | last post by:
Hello, This question is related to sharing .Net projects across solutions and is reposted from the SourceSafe group. We have several different solutions and want to share common assemblies...
5
by: cybertof | last post by:
Hi ! What is the common use of sharing a single .cs across multiple project files ? I think it's to share common classes between projects. I have actually a .cs file shared accross multiple...
1
by: JoeS | last post by:
Is there anyway to share a single pch file between projects in VC 7.0? I have 300+ projects each of which creates its own pch. All projects include the exact same header files in the precompiled...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
3
by: Shikari Shambu | last post by:
Hi All, I have a situation where multiple applications are sharing some pages/ controls. So, I have a separate common project that has the common pages/ controls. My question is how do I...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
1
by: Joe | last post by:
While I understand that Server Side Includes still work, I realize it's not the best practice for sharing code such as a common set of includes between screens. In ASP.NET I've already built...
11
by: Max Vit | last post by:
I have deployed few Access apps splitting it in Front End and Back End. Our environment uses Win XP SP2 for clients, Win 2k3 for servers and Access 2003. The max. number of clients is about 50...
8
by: Nathan Sokalski | last post by:
I have a form that contains a number of fields, all of which have validators. There are two submit buttons, one to update a record and one to add a record. Because the only difference in validation...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.