473,403 Members | 2,270 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,403 software developers and data experts.

How to raise by code the click event of a button in C#

Hi all,
I'm writing a C# program, and I was wondering: is there a way to raise
by code the click event of a Button control, as if it was the user to
have clicked on it?

Thank you very much

Nov 3 '06 #1
2 4474
Why wouldn't you just execute the method that Button.Click executes on your
form instead?
Nov 3 '06 #2
PerformClick();

But note that it is often (not always) better to simply call the backer
directly.

Exceptions would include scenarios where *you don't know* what the backer
is, or where you want it to run any code that the Button would (perhaps you
have overridden the OnClick implementation).

Marc
Nov 3 '06 #3

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

Similar topics

0
by: alexB | last post by:
You can call the sub() just like any other sub() or function() like so... Call DataGrid1_SelectedIndexChanged(sender,e ) Depending on the circumstances "sender" and "e" may be irrelevent, in...
3
by: asr | last post by:
I've a form with a button on it. How to raise (I mean to run the code within the click event of the button) without clicking the button? Is it possible to raise the events programatically.
2
by: (Pete Cresswell) | last post by:
I've been perusing a "real-life" application and notice that for instance, in a button's Click() event, they don't write the processing code. Instead, they raise an event like AddNewRecord and...
3
by: Cary Linkfield | last post by:
I have a standard form I use. It inherits from Windows.Forms.Form. I usually add a Cancel button the form in the designer. I want to raise the Cancel button's Click event when the user presses...
6
by: Li Weng | last post by:
Hi, I have a button (btnSearch) and its Click event sub btnSearch_Click. Clicking the button will trigger the event. But how do I trigger this event in code? I tried RaiseEvent btnSearch.Click...
2
by: Oney | last post by:
I want to open a popup window when user click the web server button control When user click the button, only OnClik="OpenWindow(12)" is sent but no event happend no popup opened.After...
2
by: Dave | last post by:
Hello, I'm starting with asp.net and i don't know how to raise the SelectedIndexChange event when clicking in a dropdownlist control. I thought it was the same as by clicking on a button. ...
0
by: prashantnurvi | last post by:
I have programaticaaly created several Link Buttons on my ASPX page, I would like to raise the Click event of these Link buttons, passing in appropriate parameters depending on the Link button I...
10
by: Michael Maes | last post by:
Hi, I want to have a Button.Click event 'raise' a shortcut. If eg Button1 is Clicked, I want to have a shortcut 'CTRL + F12' activated. What's the best way to acchieve this. TIA, Michael
2
by: William | last post by:
Hi I've created a page with only 'n blank table control on it. When clicking a button, the table populates with various textboxes and dropdown lists to make up a complete form. In the last row...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.