473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 12506
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(object sender, System.EventArgs e)
{
button2_Click(this.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(object sender, System.EventArgs e)
{
button2_Click(sender,e);
}
-----------------------

Kirk Graves
KRGIT Software

"OC" <nf*@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP11.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(object sender, System.EventArgs e)
{
button2_Click(this.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(object sender, System.EventArgs e)
{
button2_Click(sender,e);
}
-----------------------

Kirk Graves
KRGIT Software

"OC" <nf*@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP11.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**************@tk2msftngp13.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(object sender, System.EventArgs e)
{
button2_Click(this.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(object sender, System.EventArgs e)
{
button2_Click(sender,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**************@tk2msftngp13.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(object sender, System.EventArgs e)
{
button2_Click(this.button2,e);
}
------------------------
or, to be a little more honest, you could do this this way
------------------------
private void button1_Click(object sender, System.EventArgs e)
{
button2_Click(sender,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
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...
2
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...
5
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...
5
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...
0
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...
4
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...
2
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...
3
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.