Why the number of ticks(trackBar small lines) are changing when im running the timer?
<p>I have 48 frames/images. What i did that when i click play(button14) it will move through the images automatic.</p>

<p>But i also want that the trackBar Bar will move togeather with the timer. But if i make TrackBar1.Value = _indx;  in the timer3 tick event then after some times when its doing play over and over again the value of the trackBar change if i had 48 frames so now the trackBar have only 15 ticks and then it stop when its getting to the end on the right.</p>

<p>What i want is that if i click play it will run through the images over and over again also if i clicked pause and then continue untill i make stop.</p>

<p>In fact the trackBar value change since in the timer3 tick event i also do _indx++; and when its 15 frames on the trackBar it also stop in the end instead of continue.</p>

<pre><code>private void btnPlay_Click(object sender, EventArgs e)
{
    _indx = 0;
    DirectoryInfo dir = new DirectoryInfo(sf);

    if (_files == null)
        _files = new List&lt;FileInfo&gt;();

    FileInfo[] fi = dir.GetFiles("*.bmp");
    _files.AddRange(fi);

    _files = _files.OrderBy(f =&gt; f.LastWriteTime).ToList();
    button14.ForeColor = Color.Red;
    button13.ForeColor = Color.Black;
    button12.ForeColor = Color.Black;
    timer3.Start();
    button13.Enabled = true;
    button13.Text = "Pause";
    button12.Enabled = true;
}

private void timer3_Tick(object sender, EventArgs e)
{
    try
    {
        Image iOLd = this.pictureBox1.Image;
        Image img = Image.FromFile(_files[_indx].FullName);
        trackBar1.Value = _indx;
        label23.Text = _files[_indx].Name;
        this.pictureBox1.Image = img;

        if (iOLd != null)
            iOLd.Dispose();

        _indx++;

        if (_indx &gt;= _files.Count)
            _indx = 0;

        timer3.Interval = 10;
        timer3.Start();
    }
    catch
    {

    }
}

private void btnPause_Click(object sender, EventArgs e)
{
    button13.ForeColor = Color.Red;
    button14.ForeColor = Color.Black;
    timer3.Stop();
    if (button13.Text == "Continue")
    {
        timer3.Start();
        button13.Text = "Pause";
        return;
    }

    if (button13.Text == "Pause")
    {
        timer3.Stop();
        button13.Text = "Continue";
    }
}

private void btnStop_Click(object sender, EventArgs e)
{
    trackBar1.Value = 0;
    Image iOLd = this.pictureBox1.Image;
    Image img = Image.FromFile(_files[0].FullName);
    this.pictureBox1.Image = img;
    if (iOLd != null)
        iOLd.Dispose();
    button13.Text = "Pause";
    timer3.Stop();
    _indx = 0;
    label23.Text = _files[_indx].Name;
    button12.ForeColor = Color.Red;
    button14.ForeColor = Color.Black;
    button13.Enabled = false;
}
</code></pre>

<p>Button14 is Play button13 is Pause/Continue and Button12 is Stop The problem is that if i dont make trackBar1.Value = _indx; the trackBar wont move at all. And if i dont make _indx++; then nothing will work.</p>

<p>_files is List and _indx is int</p>
