if(lb.SelectedIndex != 2) 

解决方案 »

  1.   

     ListBox lb = new ListBox();
                if(lb.SelectedIndex != 2) 
      

  2.   


                ListBox lb = new ListBox();
                if (lb.SelectedIndex == 2)//如果 2 被选中
                    lb.SetSelected(2, false);//设置为不选中
      

  3.   

       private void listBox1_Click(object sender, EventArgs e)
            {
                if (listBox1.Items.Count > 1)
                    listBox1.SetSelected(1, false);
            }