How to pass event to parent of control

  • Thread starter Thread starter fragget
  • Start date Start date
F

fragget

hi-

i have a custom control that can be dragged onto a form.
the control can be dragged around the form with the mouse.
i want to draw a selection box around my control when it is selected
to be dragged.

on the mouse down event of my control i want to pass the
size of the control and the location to the parent so that i can
draw a selection box around it.

how can i do this?

thanks - fg
 
Hi,

I'd suggest that your form should pre-filter mouse events and react on them
before the control has a chance to handle a mouse event. If this is not
possible, the form could just subscribe to the control's MouseDown event and
handle it.

I would also like to clarify are you speaking of customizing Windows Forms
Designer behavior or are you working on some kind of custom designer?
 
i ended up having the parent subscribe to the
mousedown/mousemove event of each control placed on the
form. it seems to work well so far. originally i was
thinking of just trapping the mousedown/move on the
parent form but i couldnt think of a way to determine
which control i was on so i could retrieve the size and
upper left x,y.

this is all done run-time and not design time.

thx
-----Original Message-----
Hi,

I'd suggest that your form should pre-filter mouse events and react on them
before the control has a chance to handle a mouse event. If this is not
possible, the form could just subscribe to the control's MouseDown event and
handle it.

I would also like to clarify are you speaking of customizing Windows Forms
Designer behavior or are you working on some kind of custom designer?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

fragget said:
hi-

i have a custom control that can be dragged onto a form.
the control can be dragged around the form with the mouse.
i want to draw a selection box around my control when it is selected
to be dragged.

on the mouse down event of my control i want to pass the
size of the control and the location to the parent so that i can
draw a selection box around it.

how can i do this?

thanks - fg

.
 
Back
Top