GM3TEN
Tue May 09 12:58:28 CDT 2006
...myButton.PerformClick();
Fanor wrote:
> Thanks guys,
>
> But my problem is a bit different. Usually the click event is raised when
> the user push a mouse button, what I want to do is to send this "click" by
> code to a button control in order to raise the click event of that button.
>
> TIA
>
>
> "GM3TEN" <gmunday310@hotmail.com> wrote in message
> news:1147194957.736213.101060@y43g2000cwc.googlegroups.com...
> > Hi Fanor,
> >
> > If your control derives from either UserControl or Control you can call
> > the protected OnClick method from within your control's definition:
> >
> > this.OnClick(EventArgs.Empty);
> >
> > or, in the case you need to make this method public to consumers of
> > your control you can expose a public interface to the protected
> > "OnClick" method (the Button control already does this):
> >
> > public void PerformClick()
> > {
> > this.OnClick(EventArgs.Empty);
> > }
> >
> > Additionally, you can override the OnClick method in your derived
> > control's implementation (so your control can process other things
> > before raising the "Click" event).
> >
> > protected override void OnClick(EventArgs e)
> > {
> > //do something here before calling the base OnClick() method to
> > raise the click event.
> > base.OnClick (e);
> > }
> >
> >
> > -GM
> >
http://nonspect.com
> >
> >
> > Fanor wrote:
> >> Hi all,
> >> I want to raise the event click of a control by code. How can i do that
> >> ??
> >