passing events to UserControl

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi everyone,

Small problem we are having here, just wanted to see if anyone could help
out.

Basically we have a user control with a textbox (that is docked to fill the
whole control) that is going to be a base class for other controls. When
you place this user control on a form we want to be able to drag it around
and resize it, this in itself is not too much of a problem, and already
with a normal text box we have this working, however, when on a user control
the events are masked by the textbox that is in the way.

Is there a way to either pass the events through to teh user control in a
neat way (without screwing around in the InitialiseComponents section)? Or
can anyone suggest a better approach.

It may seem a little strange to use a usercontrol that just has a text box
on there but there is method in teh madness and it is the preferred way of
doing this for us.

I suppose if we have to we could extend the base controls but it would be
nice to be able to do it without that.

Cheers,

AndyD
 
Depending on which events you are trying to pass, you can do something as
simple as this example to get a click event. The TextBox doesn't have a
click event, so you would use the MouseUp event and in the TextBox MouseUp
event handler add this line:

this.OnClick(new EventArgs());

Use similar constructs for the other events you want to pass, but you will
have to do them event for event.

Hope this helps,

Dale
 
Back
Top