469,960 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,960 developers. It's quick & easy.

passing events to UserControl

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
Nov 16 '05 #1
1 3911
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

"Andy" <no******@somewhere.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
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

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dave Veeneman | last post: by
4 posts views Thread by Stijn Goris | last post: by
reply views Thread by Scott McChesney | last post: by
18 posts views Thread by Brett | last post: by
1 post views Thread by Apu Nahasapeemapetilon | last post: by
1 post views Thread by Lloyd Sheen | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.