title: Disabling buttons problem on C#
body: <p>Ok so I'm trying to move items from one listbox to another by using multiple buttons i.e</p>
  
  <p>I have 2 buttons cmdRight and cmdRight2 which are both disabled on form load</p>
  
  <p>If the user selects a single item on the first listbox a cmdRIght button enables but cmdRight2 is still disabled , if the user selects multiple items on the first listbox a cmdRight2 button enables but cmdRight is disabled.</p>
  
  <p>I've got the move buttons to work but the problem I'm having is after moving multiple items with the cmdRight2 button the cmdRight button enables (which it shouldn't it should only enable after selecting a single item in the listbox). I've tried numerous if statements etc. and yet it still happens. </p>
  
  <p>I'm new to C# so any help would be appreciated.</p>
  
  <p>Thank You</p>
  
  <pre><code>        private void lbList1_SelectedIndexChanged(object sender, EventArgs e)
          {
              if (this.lbList1.SelectedItems != null)
              {
                  cmdRight.Enabled = true; //enable cmdRight
                  cmdClear.Enabled = true; //enable cmdClear
                  if (this.lbList1.SelectedItems.Count &gt; 1)//if multiple items selected
                  {
                      cmdRight.Enabled = false;
                      cmdRight2.Enabled = true; //enable cmdRight2              
                  }
              }
          }
  
  
      private void cmdRight2_Click(object sender, EventArgs e)
      {
          foreach (int i in lbList1.SelectedIndices)
          {
              lbList2.Items.Add(lbList1.Items[i].ToString());
          }
          while (lbList1.SelectedItems.Count &gt; 0)
          {
              lbList1.Items.Remove(lbList1.SelectedItems[0]);
          }
          cmdRight2.Enabled = false;
  
      }
  
      private void cmdRight_Click(object sender, EventArgs e)
      {
          lbList2.Items.Add(lbList1.SelectedItem); //Add selected item from list1 to list2
          lbList1.Items.Remove(lbList1.SelectedItem);//remove the selected item in list1
  
          cmdRight.Enabled = false; //disable cmdRight
      }
  </code></pre>