I want to know, if there is any way to raise an event of a standard
control programmatically. Scenario is that I want to raise the click
event of a button control upon changing the text of a text box
control. How can I do that?
Just call the handler and pass it the appropriate references. Yes, it really is just that easy.
On Mon, Jun 9, 2008 at 3:22 AM, mrscorp...@gmail.com <MrScorp...@gmail.com> wrote:
> Hi All,
> I want to know, if there is any way to raise an event of a standard > control programmatically. Scenario is that I want to raise the click > event of a button control upon changing the text of a text box > control. How can I do that?
> Thanks in Advance. > Happy Programming! > Adeel.
> I want to know, if there is any way to raise an event of a standard
> control programmatically. Scenario is that I want to raise the click
> event of a button control upon changing the text of a text box
> control. How can I do that?
Thanks for your response. It was kind of you.
But call to the handler is not raising event. My statement was I want
to raise event i.e. button automatically calls handler once I raise
event on that button. Just wondering if it is possible to raise events
on the controls.
I feel my example previously was not good enough to make it clear as
to what exactly i want. Let me explain the exact scenario as to why I
need raising event.
I have developed a custom button control which is derived from Control
class. My control fires click event upon clicking but I also want to
fire click event when user presses enter or space key on that
control.
Currently I have solved my problem by implementing my own event
ButtonClick, which I fire each time when someone clicks or presses
space or enter key. But I don't want two events like Click or
ButtonClick, I just want one event and that is Click event, which is
the already there in Control class. How to fire that event of that
super class upon keypress?
Thanks in Advance.
Happy Programming!
Adeel.
On Jun 9, 10:27 pm, "Andrew Badera" <and...@badera.us> wrote:
> Just call the handler and pass it the appropriate references. Yes, it really
> is just that easy.
> On Mon, Jun 9, 2008 at 3:22 AM, mrscorp...@gmail.com <MrScorp...@gmail.com>
> wrote:
> > Hi All,
> > I want to know, if there is any way to raise an event of a standard
> > control programmatically. Scenario is that I want to raise the click
> > event of a button control upon changing the text of a text box
> > control. How can I do that?
> Thanks for your response. It was kind of you. > But call to the handler is not raising event. My statement was I want > to raise event i.e. button automatically calls handler once I raise > event on that button. Just wondering if it is possible to raise events > on the controls.
> I feel my example previously was not good enough to make it clear as > to what exactly i want. Let me explain the exact scenario as to why I > need raising event. > I have developed a custom button control which is derived from Control > class. My control fires click event upon clicking but I also want to > fire click event when user presses enter or space key on that > control. > Currently I have solved my problem by implementing my own event > ButtonClick, which I fire each time when someone clicks or presses > space or enter key. But I don't want two events like Click or > ButtonClick, I just want one event and that is Click event, which is > the already there in Control class. How to fire that event of that > super class upon keypress?
> Thanks in Advance. > Happy Programming! > Adeel.
> On Jun 9, 10:27 pm, "Andrew Badera" <and...@badera.us> wrote: > > Just call the handler and pass it the appropriate references. Yes, it > really > > is just that easy.
> > On Mon, Jun 9, 2008 at 3:22 AM, mrscorp...@gmail.com < > MrScorp...@gmail.com> > > wrote:
> > > Hi All,
> > > I want to know, if there is any way to raise an event of a standard > > > control programmatically. Scenario is that I want to raise the click > > > event of a button control upon changing the text of a text box > > > control. How can I do that?
If you have a custom class based on the Control class, then the event that is triggered is for your class, not the Control class. You can, however, call the base class' event handler as part of your event handler.
After you implement the processing you want, simply register the event handler for all the events you want to execute that code.
...Glenn
On 6/10/08, mrscorp...@gmail.com <MrScorp...@gmail.com> wrote:
> Thanks for your response. It was kind of you. > But call to the handler is not raising event. My statement was I want > to raise event i.e. button automatically calls handler once I raise > event on that button. Just wondering if it is possible to raise events > on the controls.
> I feel my example previously was not good enough to make it clear as > to what exactly i want. Let me explain the exact scenario as to why I > need raising event. > I have developed a custom button control which is derived from Control > class. My control fires click event upon clicking but I also want to > fire click event when user presses enter or space key on that > control. > Currently I have solved my problem by implementing my own event > ButtonClick, which I fire each time when someone clicks or presses > space or enter key. But I don't want two events like Click or > ButtonClick, I just want one event and that is Click event, which is > the already there in Control class. How to fire that event of that > super class upon keypress?
> Thanks in Advance. > Happy Programming! > Adeel.
First of all thank you for your input. What you are suggesting is to register a handler with event. That will only execute the code I've written in the handler while implementing that control but will not raise the click event on my custom control i.e. the code written by user of the control in the click event handler at design time will not be called, because handler is being called whenever click event is raised, but my problem is to raise event upon key press and that click event handler code written by the user of the control at design time should also run upon that key press.
But my problem is solved now. I just wanted to share how I solved the problem so it maybe helpful for others as well.
I called the OnClick method of the Control class to raise click event upon keypress i.e. upon pressing enter or space when control is in focus. This way click event is raised for the control so that the click event handler written by the user of the control at design time is also executed each time some one presses space bar or enter key when this control is in focus, not just the handler which is written inside the implementation of control.
I hope I've made my point clear.
Thank you all for your input. Happy Programming! Adeel.
On Wed, Jun 11, 2008 at 6:32 PM, Glenn <ke4ktza...@gmail.com> wrote:
If you have a custom class based on the Control class, then the event that
> is triggered is for your class, not the Control class. You can, however, > call the base class' event handler as part of your event handler.
> After you implement the processing you want, simply register the event > handler for all the events you want to execute that code.
> ...Glenn
> On 6/10/08, mrscorp...@gmail.com <MrScorp...@gmail.com> wrote:
>> Hi,
>> Thanks for your response. It was kind of you. >> But call to the handler is not raising event. My statement was I want >> to raise event i.e. button automatically calls handler once I raise >> event on that button. Just wondering if it is possible to raise events >> on the controls.
>> I feel my example previously was not good enough to make it clear as >> to what exactly i want. Let me explain the exact scenario as to why I >> need raising event. >> I have developed a custom button control which is derived from Control >> class. My control fires click event upon clicking but I also want to >> fire click event when user presses enter or space key on that >> control. >> Currently I have solved my problem by implementing my own event >> ButtonClick, which I fire each time when someone clicks or presses >> space or enter key. But I don't want two events like Click or >> ButtonClick, I just want one event and that is Click event, which is >> the already there in Control class. How to fire that event of that >> super class upon keypress?
>> Thanks in Advance. >> Happy Programming! >> Adeel.