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