How to move the elements of list box up and down after displaying their properties?
<p>I created a code wherein when i select an item in a list box, the info about the item gets displayed in a text box. I also have move up and down buttons to move the contents of the list up and down and delete button to delete the selected item. Now when i click on the item the info is getting displayed in the text box but if i click on move up, down or delete button for the same item then exception is thrown Object reference not set to an instance of an object. The line that throws this exception is when i am creating a new object of ClassName in the code below:</p>

<pre><code>    private void lb_SelectedIndexChanged(object sender, EventArgs e)
    {
        m_Txt.Clear();
        ClassName fileInfo = new ClassName(m_lbOPFfiles.SelectedItem.ToString());
        m_Txt.Multiline = true;
        m_Txt.Text = fileInfo.title + Environment.NewLine + fileInfo.ID + Environment.NewLine + fileInfo.time;

    }
</code></pre>

<p>the code for move up button is:</p>

<pre><code>    private void m_btnUP_Click(object sender, EventArgs e)
    {            
        if (m_lbOPFfiles.SelectedIndex != 0 &amp;&amp; m_lbOPFfiles.SelectedIndex != -1)
        {
          //  m_lbOPFfiles.SelectedItem.
            object item = m_lbOPFfiles.SelectedItem;
            int index = m_lbOPFfiles.SelectedIndex;
            m_lbOPFfiles.Items.RemoveAt(index);

            m_lbOPFfiles.Items.Insert(index - 1, item);
        }         
    }
</code></pre>

<p>Please tell what possibly could be the problem and the solution for it.</p>
