Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7505439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:54:45+00:00 2026-05-29T21:54:45+00:00

i have code that reads from a file and streams it through a label.

  • 0

i have code that reads from a file and streams it through a label. but when i uncheck the checkbox and check it again it just picks up from where it left off

this is my code

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (checkBox1.Checked == true)
        {
            timer1.Enabled = true;
            timer1.Start();
        }
        else
        {
            timer1.Enabled = false;
        }
    }
    private int start = 0;
    private string lyricspath = @"lyrics.txt";
    private void timer1_Tick(object sender, EventArgs e)
    {
        TextReader reader = new StreamReader(lyricspath);
        string[] read = File.ReadAllLines(lyricspath);
        string join = string.Join(" ", read);
        int number = join.Length;
        start++;
        string str = join.Substring(start, 15);
        if (start == number - 15)
        {
            start = 0;
        }
        label1.Text = str;
    }

is there any way to make the timer start completely over each time i uncheck then check the checkbox?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:54:46+00:00Added an answer on May 29, 2026 at 9:54 pm

    If you reset your start to zero on the check change event, that should reset the timer:

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                start = 0;
                label1.Text = string.Empty;
                timer1.Enabled = true;
                timer1.Start();
            }
            else
            {
                timer1.Enabled = false;
            }
        }
    

    I have a similar process in which I start a timer when a form loads, then if they have a form open for a period of time I give them the option to keep the form open. If they do, then I reset the timer count to zero and the process starts over.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some C# code that reads data from a text file using a
In my .aspx.cs I have a code that reads a .xml file and I
I have loads of c++ classes that reads data from a file stream. The
I have the following simple code, that reads contents of a text file into
I have the following code that reads the content of a url public static
I have a bit of code that basically reads an XML document using the
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have some code that allows users to upload file attachments into a varbinary(max)
I have a program that load data from a file using std::ifstream and store
I have a business layer class that uses System.IO.File to read information from various

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.