你什么意思?有什么问题吗?把问题写清楚!

解决方案 »

  1.   

    删除排在最后一个元素会出错。
      

  2.   

    大哥们大姐们,帮帮忙。
      

  3.   

    改一改你的删除语句
    private void button2_Click(object sender, System.EventArgs e)
    {
    if(this.comboBox1.Items.Count>0)
             {
    try
    {
    int i = this.comboBox1.SelectedIndex;   <------
    this.comboBox1.SelectedIndex = -1;      <------
    this._testdate.RemoveAt(i);             <------
    this.comboBox1.DataSource=null;           this.comboBox1.DataSource=this._testdate;
             this.comboBox1.DisplayMember="name";
    this.comboBox1.ValueMember="id";
    }
    catch(Exception ex)
    {
    Console.Out.WriteLine(ex.Message);
    }
    //this.comboBox1.SelectedIndex=0;
    }
    }