By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

passing events to UserControl

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.