C#实现一个功能:
   实现combobox选中一个值,下次选择时之前那个值自动删除。其中combobox的值是用Load事件加载的。比如说之前是“1,2,3”选择了“1”,下次选择时只剩“2,3”
     

解决方案 »

  1.   


            private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
            {
                comboBox2.Items.RemoveAt(comboBox2.SelectedIndex);
            }
      

  2.   

    private void comboBox1_Click(object sender, EventArgs e)
    {
    comboBox1.Items.Remove(comboBox1.Text);
    }
      

  3.   

    // 定义个全局变量
    private int index = -1;// 加载示例
    var list = new string[] { "1", "2", "3" };
    foreach (var item in list)
    {
        this.comboBox1.Items.Add(item);
    }// 注册 SelectedIndexChanged 事件
    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.index >= 0)
        {
            comboBox1.Items.RemoveAt(this.index);
        }
        this.index = this.comboBox1.SelectedIndex;
    }
      

  4.   

    什么意思,DataSource 赋值?