473,473 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

add click event to button in VS2k3 c#

how to add an event click to button in C# using visual studio 2003

i know i can double click on the button

but is there any other way through the code?
Jan 2 '06 #1
4 2062
You mean programmatically, at runtime?
this.Button1.Click+=new EventHandler(Button_Click);

Where Button_Click is your eventhandler for buttons. Inside the handler you
can find out which button with:

((Button)sender).ID ;

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"John" wrote:
how to add an event click to button in C# using visual studio 2003

i know i can double click on the button

but is there any other way through the code?

Jan 2 '06 #2
In your code-behind, start a new method called Button1_Click with the proper
parameters. However, this is not really any different than double-clicking
the button from the designer. So, is this what you wanted to know or are
you looking from something different?
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"John" <jo**@smith.com> wrote in message
news:dp**********@news2.netvision.net.il...
how to add an event click to button in C# using visual studio 2003

i know i can double click on the button

but is there any other way through the code?

Jan 2 '06 #3
Hi John,

There are several ways to add an event:

1. Double click the control: only for the default event, such as
Button_Click, DropDownList_SelectedIndexChanged,
DataGrid_SelectedIndexChanged, and so on.

2. In Page Design View, select control. Then in Properties window click
events tab (Flash sign), select an event and double click it.

3. In InitializeComponent, type controlName.eventName += (Tab Key twice)

HTH

Elton Wang

"John" wrote:
how to add an event click to button in C# using visual studio 2003

i know i can double click on the button

but is there any other way through the code?

Jan 2 '06 #4
Tnxxxxxxxxxxx
"Elton W" <El****@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Hi John,

There are several ways to add an event:

1. Double click the control: only for the default event, such as
Button_Click, DropDownList_SelectedIndexChanged,
DataGrid_SelectedIndexChanged, and so on.

2. In Page Design View, select control. Then in Properties window click
events tab (Flash sign), select an event and double click it.

3. In InitializeComponent, type controlName.eventName += (Tab Key twice)

HTH

Elton Wang

"John" wrote:
how to add an event click to button in C# using visual studio 2003

i know i can double click on the button

but is there any other way through the code?

Jan 2 '06 #5

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

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
6
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but...
2
by: Liqun Xu | last post by:
Hallo NG, I created a Button with Click-Event dynamically: System.Web.UI.WebControls.Button bt_1 = new Button(); bt_1.Click += new EventHandler(bt_1_click); and I implemented the Funktion...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
3
by: GauravGupta | last post by:
i want to know that is it posible to call button click event before page load event on post back.... please help me....
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...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
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.