|
-
Feb 3rd, 2006, 02:48 PM
#1
Thread Starter
Hyperactive Member
Single Button To Start and Stop?[RESOLVED]
I was woundering can you get a Single button to peform 2 Actions :
Start on First Click and then Stop when RE Clicked again??
Code:
private void command4_Click(object eventSender, System.EventArgs eventArgs)
{
if (toolStripStatusLabel1.Text = "blah blah blah";_
Timer1.Enabled = true);
}
else
{
PacketsLabel.Text = "0";
Timer1.Enabled = false;
}
I know that not Correct above but I think you get the Idea of what i'm trying to do.This should be Much easier than the last one...LOL
Thxs in advance..
Last edited by Rattlerr; Feb 3rd, 2006 at 03:03 PM.
-
Feb 3rd, 2006, 02:52 PM
#2
Fanatic Member
Re: Single Button To Start and Stop?
Sure, why not, just use a state management variable.
Code:
bool TimerOn=false; //(Put this at the class level not in the Proc)
if(TimerOn)
{
TimerOn=false;
//Do whatever else
}
else
{
TimerOn=true;
//Do whatever else
}
-
Feb 3rd, 2006, 03:04 PM
#3
Thread Starter
Hyperactive Member
Re: Single Button To Start and Stop?[RESOLVED]
Thxs for the Help Appreicate it..
-
Feb 4th, 2006, 02:53 AM
#4
Re: Single Button To Start and Stop?[RESOLVED]
This may or may not be of interest to you but the CheckBox control has an Appearance property that can be set to Button. It will look exactly like a Button control but operates as a toggle, so when you click it it stays depressed until you click it again. The depressed state corresponds to Checked = True. RadioButtons can behave like this too.
-
Feb 4th, 2006, 03:07 AM
#5
Thread Starter
Hyperactive Member
Re: Single Button To Start and Stop?[RESOLVED]
Cool...I'll keep that in mind jmcilhinney..Thxs
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|