Notify Events to Parent

A

anand

Hello,

I have created a Custom Windows Control in C# (.NET 2003).
I have a PictureBox in that control.

I want to expose the single MouseMove event of the control to the client.
So that the MouseMoveEventHandler from the client will know where the mouse
is.

Is there any way to send the PictureBox MouseMove event to the Control (i.e.
parent)?

So finally only one MouseMove event will be exposed to the client. and
client will know where the mouse is.

Thank you,
-Anand
 
J

John Saunders

anand said:
Hello,

I have created a Custom Windows Control in C# (.NET 2003).
I have a PictureBox in that control.

I want to expose the single MouseMove event of the control to the client.
So that the MouseMoveEventHandler from the client will know where the mouse
is.

Is there any way to send the PictureBox MouseMove event to the Control (i.e.
parent)?

So finally only one MouseMove event will be exposed to the client. and
client will know where the mouse is.

Have your custom control handle the MouseMove event of the PictureBox. Also,
since your custom control derives from Control, it already exposes a
MouseMove event of its own. In the PictureBox_MouseMove handler in your
custom control, raise the custom controls' MouseMove event:

private void InitializeComponent()
{
...
_pictureBox.MouseMove += new MouseEventHandler(PictureBox_MouseMove);
}


private void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
this.OnMouseMove(e);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top