Results 1 to 5 of 5

Thread: Single Button To Start and Stop?[RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member Rattlerr's Avatar
    Join Date
    Jul 2005
    Location
    FloralCity,Florida
    Posts
    269

    Resolved 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.

  2. #2
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    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
    }

  3. #3

    Thread Starter
    Hyperactive Member Rattlerr's Avatar
    Join Date
    Jul 2005
    Location
    FloralCity,Florida
    Posts
    269

    Re: Single Button To Start and Stop?[RESOLVED]

    Thxs for the Help Appreicate it..

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member Rattlerr's Avatar
    Join Date
    Jul 2005
    Location
    FloralCity,Florida
    Posts
    269

    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
  •  



Click Here to Expand Forum to Full Width