473,394 Members | 1,778 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,394 software developers and data experts.

MouseDown Event

JJ
Hi All,

I need to create a MouseDown event for a picture box . Am I doing the
following right?

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)

Then

Create Event
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)
{

// code etc....

}

Thanks,

JJ
Nov 13 '05 #1
2 16266
What do you mean by, " Then Create Event"? Your code is ambiguous. When
you add the event handler to the pictureBox, you pass in the function
pictureBox_MouseDown, but your function is called pictureBox_OnMouseDown.
Is this a typo?

The code should look like the following, assuming that pictureBox and
pictureBox_MouseDown exist in the same class:

// in initialization (perhaps in the constructor) add event handler to the
PictureBox
// This actually creates the event delegate and adds it to the list of
MouseDown delegates for pictureBox.
// When the MouseDown event is raised by pictureBox(i.e. when you press a
mouse button on the pictureBox),
// the function pictureBox_MouseDown will get executed.
pictureBox.MouseDown += new MouseEventHandler(this.pictureBox_MouseDown)

// the MouseDown event handler
private void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
// do whatever you need to do.
}

Hope this helps,
Jerome
"JJ" <jm***@bellatlantic.net> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I need to create a MouseDown event for a picture box . Am I doing the
following right?

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)

Then

Create Event
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)
{

// code etc....

}

Thanks,

JJ

Nov 13 '05 #2

pictureBox.MouseDown += new
System.WinForms.MouseEventHandler(pictureBox_Mouse Down)
public void pictureBox_OnMouseDown(object sender,
System.WinForms.MouseEventArgs e)

// No! use the same name:
pictureBox_MouseDown
Nov 13 '05 #3

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

Similar topics

3
by: Deborah V. Gardner | last post by:
I have a list box and would like to point to an item and have a textbox popup referencing a column in the list box. On the list box's MouseDown event I have the following Dim strFullText ...
1
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the...
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
4
by: rsmith | last post by:
How can I capture the MouseDown event on a Label ? I entered thr following code and got a " cannot handle Event 'MouseDown' because they do not have the same signature." Private Sub...
1
by: Merlin | last post by:
I have created a UserControl which has a label; what I wish to do is place this UserControl on a form and then trap the Mouse Down event, whenever someone clicks my control. My problem is that the...
2
by: Rob | last post by:
How can I fix the following warning warning BC40004: sub 'MouseDown' conflicts with event 'MouseDown' in the base class 'Control' and so should be declared 'Shadows'. This warning appears...
1
by: Alan | last post by:
i have a form with a label on it Private Sub Label1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown ' do stuff End Sub ...
1
by: JDeats | last post by:
It appears the WinForm MouseDown and MouseUp event handlers are not working properly. In the "bare bones" sample application below, Form1_MouseUp gets called even through the mouse button remains...
6
by: jpatchak | last post by:
Hello, I am trying to create a context menu for right clicking on a TreeView control (for deleting, etc...), using either the MouseDown or MouseUp event. When I put following code in: Private...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.