Why when coloring an item in Red then back to Blue(original color) im getting exception?
<p>The code:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using unfreez_wrapper;
using WindowsFormsApplication1;
using DannyGeneral;
using System.Text.RegularExpressions;
using Extracting_Frames;

namespace Lightnings_Extractor
{
    public partial class Lightnings_Mode : Form
    {
        private List&lt;int&gt; m_itemIndexes = new List&lt;int&gt;();
        private int m_lastSelectedIndex = 0;
        Lightnings_Extractor.PDF pdf1;
        public static string item;
        Form1 f1 = null;
        List&lt;string&gt; recentItems = new List&lt;string&gt;();

        public Lightnings_Mode(Form1 f1)
        {
            InitializeComponent();


            pdf1 = new Lightnings_Extractor.PDF();
            this.f1 = f1;
        }

        private void Lightnings_Mode_Load(object sender, EventArgs e)
        {
            this.Size = new Size(416, 506);
            this.Location = new Point(23, 258);
            listBoxIndexs();
            this.listBox1.SelectedIndex = 0;
        }

        private void listBoxIndexs()
        {
            for (int i = 0; i &lt; Form1.lightningsRegions.Count; i++)
            {

                    listBox1.Items.Add(Form1.lightningsRegions[i]);

            }
        }

        private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            item = listBox1.SelectedItem.ToString();
            this.f1.PlayLightnings();
            f1.pdftoolsmenu();
            if (item != null &amp;&amp; !pdf1.Lightnings.Contains(item.ToString()))
            {
                pdf1.Lightnings.Add(item.ToString());             
            }
        }

        private void listBox1_MouseDown(object sender, MouseEventArgs e)
        {
            int index = listBox1.IndexFromPoint(e.X, e.Y);
            listBox1.SelectedIndex = index;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (m_itemIndexes.Contains(index))
                    return;

                m_itemIndexes.Add(index);
                DrawItem(index);
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (!m_itemIndexes.Contains(index))
                    return;

                m_itemIndexes.RemoveAt(index);
                DrawItem(index);
            }

        }

        private void DrawItem(int index)
        {
            Rectangle rectItem = listBox1.GetItemRectangle(index);
            listBox1.Invalidate(rectItem);
        }

        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            bool coloring = m_itemIndexes.Contains(e.Index);
            if (coloring)
            {
                e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, e.State, e.ForeColor, Color.Red);
            }

            bool selected = (e.State &amp; DrawItemState.Selected) == DrawItemState.Selected;

            e.DrawBackground();

            string item = listBox1.Items[e.Index].ToString();
            e.Graphics.DrawString(item, e.Font, selected || coloring ? Brushes.White : Brushes.Black, e.Bounds, StringFormat.GenericDefault);

            if (selected)
                e.DrawFocusRectangle();

        }

    }
}
</code></pre>

<p>Im getting an exception on this line:</p>

<pre><code>m_itemIndexes.RemoveAt(index);
</code></pre>

<p>After playing with the listBox while my application is running clicking right and left click buttons again and again on some items same items it's throwing the exception on this line.</p>

<p>In this case index is 16. Index was out of range. Must be non-negative and less than the size of the collection.
 Parameter name: index</p>

<p>This line is in listBox1_MouseDown event.</p>

<p>Some problems i found maybe they are also connected to this exception:</p>

<p>Some problems:</p>

<ol>
<li><p>When clicking first time or any time on right click button on an item so if im on item 10 now if i click on item 13 it will color item 10 in Red.</p>

<p>then if i click on item 21 right click it will color item 13 in Red . But i wanted that if i click on item 21 it will color item 21 in Red clicking on item 10 color item 10 click on item 13 then 13 and not to color the last clicked item but color in Red the current clicked item !</p></li>
<li><p>After marked some items in Red let's say 7 items in Red i click on them with left button to change them back to regular color after 3-4 items it's throwing me the exception above on the index variable as i mentioned above !</p></li>
</ol>
