473,396 Members | 1,900 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,396 software developers and data experts.

Firing Events

Hi NG
maybe it's a silly question
if i have 2 buttons on a Windows Form,
button1 and button2:
button1 has delegates subscribed

this.button1.Click += new EventHandler(this.MethodA);
this.button1.Click += new EventHandler(this.MethodB);
.... // etc etc
i register a method to the Click even delegate
this.button2.Click += new EventHandler(this.RaiseClick);
In RaiseClick method a'd like to fire button1.Click event; how to?

private void RaiseClick( object sender, EventArgs e )
{
// Something like that
button1.Click( sender, e ); --> not accessible
}
( Well, i know that i have to manipulate sender and e, but it's not a
problem )

Thanks: Christian.
Nov 15 '05 #1
4 3649
See Button.PerformClick()
"Christian" <pl***********************@novasoftware.it> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi NG
maybe it's a silly question
if i have 2 buttons on a Windows Form,
button1 and button2:
button1 has delegates subscribed

this.button1.Click += new EventHandler(this.MethodA);
this.button1.Click += new EventHandler(this.MethodB);
... // etc etc
i register a method to the Click even delegate
this.button2.Click += new EventHandler(this.RaiseClick);
In RaiseClick method a'd like to fire button1.Click event; how to?

private void RaiseClick( object sender, EventArgs e )
{
// Something like that
button1.Click( sender, e ); --> not accessible
}
( Well, i know that i have to manipulate sender and e, but it's not a
problem )

Thanks: Christian.

Nov 15 '05 #2
how about this.button1_click(this,new Eventargs)

what is button1_click? a method ?
I have e general button, i don't know which are the methods subscribed to
its Click Event...
Think i have e method:
public void RayseClick( Button bn ){
bn.Click( .. );
}
Nov 15 '05 #3
Hi Christian,

Christian wrote:
Hi NG
maybe it's a silly question
if i have 2 buttons on a Windows Form,
button1 and button2:
button1 has delegates subscribed

this.button1.Click += new EventHandler(this.MethodA);
this.button1.Click += new EventHandler(this.MethodB);
... // etc etc
i register a method to the Click even delegate
this.button2.Click += new EventHandler(this.RaiseClick);
In RaiseClick method a'd like to fire button1.Click event; how to?

private void RaiseClick( object sender, EventArgs e )
{
// Something like that //> button1.Click( sender, e ); --> not accessible

button1.PerformClick();
}
( Well, i know that i have to manipulate sender and e, but it's not a
problem )

Thanks: Christian.


Regards

Marcin

Nov 15 '05 #4
Well, you could inherit from Button class and provide a way to invoke
protected method OnMouseDown through a new public method. The problem with
firing this event - you'll have to fake the event arguments (since no actual
event is happening). For instance:

public class MyButton : Button

{

public void OnMouseDown()

{

base.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));

}

}

"Christian" <pl***********************@novasoftware.it> wrote in message
news:uE*************@tk2msftngp13.phx.gbl...
Thanks Val for your answer
It's nearly what i need,
indeed a need firing MouseDown event too
Ideas?
"Val Savvateev" <vs********@meridium.com_NO_SPAM> ha scritto nel messaggio
news:e0**************@TK2MSFTNGP09.phx.gbl...
See Button.PerformClick()


Nov 15 '05 #5

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

Similar topics

3
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace...
7
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when...
4
by: Woody Splawn | last post by:
I had it happen again today that I needed some code to run upon loading the form but the code that I needed to have run needed to run AFTER all the rest of Visual Studio's events had fired. Due to...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
5
by: Joe | last post by:
Hi I am adding a class to a ComboBox - and all is fine except that I fill the combobox on the Form_Load Method and it causes the method private void comboBox2_SelectedIndexChanged(object...
0
by: RobKinney1 | last post by:
Hello, One of our C# apps (2.0) depends on a few events. One of them being DocumentComplete. Well, everything works fine with users that have IE 6 installed on their computers. But we noticed...
2
by: mswlogo | last post by:
I looked high and low for code to do this and finally found some VB code that did it right. This is a C# flavor of it. public event EventHandler<EventArgsMyEventToBeFired; public void...
1
by: TimmyTurner | last post by:
Hi all I'm working on a ASP.NET, C# project on Visual Studio 2005, using a MSDB in _vista_. My problem is that the events for the buttons are not firing. I've searched the web and the solution...
4
by: Joergen Bech | last post by:
I sometimes use delegates for broadcasting "StateChanged" events, i.e. if I have multiple forms and/or controls that need updating at the same time as the result of a change in a global/common...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.