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

button click

How can I have more the one event on button click?

First click --> one event
Second click --> second event

Hrcko
Nov 17 '05 #1
3 1987
"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:df**********@ss405.t-com.hr...
How can I have more the one event on button click?

First click --> one event
Second click --> second event


You could make do with 1 event if you have the client's handler remove
itself and add another handler...

private void OnClick( object sender, ClickEventArgs e )
{
// Do something
myForm.Click -= new ClickEventHandler( OnClick );
myForm.Click += new ClickEventHandler( OnSecondClick );
}

private void OnSecondClick( object sender, ClickEventArgs e )
{
// Do something
myForm.Click -= new ClickEventHandler( OnSecondClick );
myForm.Click += new ClickEventHandler( OnClick );
}
Or, you could simply create a custom control with 2 events.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
Nov 17 '05 #2
Hrvoje Voda wrote:
How can I have more the one event on button click?

First click --> one event
Second click --> second event


Depends on your requirements. It sounds like some kind of state machine you are
after here. The state could be held in a class variable or even in the control
itself - the Tag property comes to mind. Or if a simple toggle is all you need
you can even do something really ugly like:

if (btn.Caption == "On")
{
turn_the_damn_thing_on();
btn.Caption = "Off";
}
else
{
turn_the_damn_thing_off();
btn.Caption = "On";
}

Crude but effective,
-rick-
Nov 17 '05 #3
Hrvoje Voda wrote:
How can I have more the one event on button click?

First click --> one event
Second click --> second event


Depends on your requirements. It sounds like some kind of state machine you are
after here. The state could be held in a class variable or even in the control
itself - the Tag property comes to mind. Or if a simple toggle is all you need
you can even do something really ugly like:

if (btn.Caption == "On")
{
turn_the_damn_thing_on();
btn.Caption = "Off";
}
else
{
turn_the_damn_thing_off();
btn.Caption = "On";
}

Crude but effective,
-rick-
Nov 17 '05 #4

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

Similar topics

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...
1
by: Klaus Jensen | last post by:
Hi! This has been annoying me all day, and I can't get it to work It is really driving me nuts! Basicly this simple webapp created to illustrate my problem, renders five buttons, and adds a...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
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,...
9
by: Jonathan Wood | last post by:
Does anyone know of any reason a button on a master page would have no effect? I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I could have something odd that is...
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
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
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
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
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.