473,568 Members | 2,882 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I fire another event from within an event?

OC
I would like to trigger another event from within an event that is specific
to a forms state at the time of the original event.

Is this possible?
Nov 15 '05 #1
5 12525
OC wrote:
I would like to trigger another event from within an event that is specific
to a forms state at the time of the original event.

Is this possible?


Sure, there is no reason the handler for an event can't fire another event.
Nov 15 '05 #2
Sure. For instance, lets say you want to fire the click event for button2
from the click event for button1 you could do this:

-------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(t his.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(s ender,e);
}
-----------------------

Kirk Graves
KRGIT Software

"OC" <nf*@nospam.com > wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I would like to trigger another event from within an event that is specific to a forms state at the time of the original event.

Is this possible?

Nov 15 '05 #3
Sure. For instance, lets say you want to fire the click event for button2
from the click event for button1 you could do this:

-------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(t his.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(s ender,e);
}
-----------------------

Kirk Graves
KRGIT Software

"OC" <nf*@nospam.com > wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I would like to trigger another event from within an event that is specific to a forms state at the time of the original event.

Is this possible?

Nov 15 '05 #4
Hi Kirk,

"Kirk Graves" <kr***********@ yahoo.com> wrote in message
news:OK******** ******@tk2msftn gp13.phx.gbl...
Sure. For instance, lets say you want to fire the click event for button2
from the click event for button1 you could do this:

-------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(t his.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(s ender,e);
}
-----------------------


The above code is actually calling another method that may or may not
also be an event handler for button2's click event. If you actually wanted
to raise a given event for a control, you would call the appropriate
On[EventName] method. Of course the On[EventName] methods are protected,
which means you can only do this from the class itself or an inheriting
class. One exception to this rule happens to be the Button control, which
has a public PerformClick method (which does little more than call the
protected OnClick method).

Regards,
Dan
Nov 15 '05 #5
Hi Kirk,

"Kirk Graves" <kr***********@ yahoo.com> wrote in message
news:OK******** ******@tk2msftn gp13.phx.gbl...
Sure. For instance, lets say you want to fire the click event for button2
from the click event for button1 you could do this:

-------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(t his.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(o bject sender, System.EventArg s e)
{
button2_Click(s ender,e);
}
-----------------------


The above code is actually calling another method that may or may not
also be an event handler for button2's click event. If you actually wanted
to raise a given event for a control, you would call the appropriate
On[EventName] method. Of course the On[EventName] methods are protected,
which means you can only do this from the class itself or an inheriting
class. One exception to this rule happens to be the Button control, which
has a public PerformClick method (which does little more than call the
protected OnClick method).

Regards,
Dan
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2489
by: Li Zhang | last post by:
I have a user control contain one datagrid. this datagrid contains one button column with commandName "Review", I have event handler datagrid_ItemCommand to handle this event and also wired the event when initial. but when I put this user control in a web form, click the review link(it is linkbutton) will not fire the event. Any one have any...
2
5146
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as I am new to this. Full code below : using System; using System.Collections; using System.ComponentModel;
5
6786
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only way is using javascript - does anybody have a sample for this ? Thanks
5
10359
by: Verde | last post by:
This is admittedly an apparently odd request... but please indulge me if you don't mind: Suppose I have two <asp:Button.../> on a page (Button1 and Button2). User clicks Button1 and triggers a PostBack. How can I then fire the click event of Button2 during the same PostBack? I know this seems like a totally bad situation I'm creating out...
0
2482
by: jonathan.beckett | last post by:
I have been working on a client project recently that is using winforms ..NET user controls within web pages in Internet Explorer, and need to find out how to make the user control communicate back to the webpage (typically to tell it that it has finished doing something). I started digging around and found out that I needed to implement a COM...
4
5291
by: Ty Salistean | last post by:
So, here is a wierd question that we have been discussing for a bit now. Does an event fire even though nothing is subscribed to listen to the event? For instance, does the Click event of a button fire even though nothing is subscribed to listen to the event. The answer is NO in a traditional Publisher/Subscriber design pattern (at least...
2
3902
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever...
3
7533
by: =?Utf-8?B?SlA=?= | last post by:
<asp:GridView ID="gridResults" runat="server" AutoGenerateColumns="False" Width="98%" PageSize="25" AllowPaging="True" OnSorting="gridResults_Sorting" OnPageIndexChanging ="gridResults_PageIndexChange" AllowSorting="True" OnRowDataBound="gridResults_RowDataBound" EnableViewState="False" OnRowCommand="gridResults_Command" ></asp:GridView> ...
1
2131
by: dave102 | last post by:
I am developing a page which uses DIY drag i.e. I cancel ondragstart, ondragover with window.event.returnValue=false; and simply create a drag image from the image I click on (with 60% opacity to make it look "ghosted") then I move it using the body.onmouseover event positioning my drag image inside a <div> with absolute positioning. I make sure...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.