要实现的功能,单击listview1的任一行,listview2显示以listview1莫一列值为关键字的所有数据
private void lvwEquipmentInfo_SelectedIndexChanged(object sender, EventArgs e)
        {
DataRow[] rows = dt.Select("eq_codenum='" + this.lvwEquipmentInfo.SelectedItems[0].SubItems[1].Text.ToString() + "'"); //InvalidArgument=“0”的值对于“index”无效。 参数名: index
            for (int i = 0; i < rows.Length; i++)
            {
             .....
            }}

解决方案 »

  1.   

    DataRow[] rows = dt.Select("eq_codenum='" + this.lvwEquipmentInfo.SelectedItems[0].Text + "'"); 
    lvwEquipmentInfo几列
      

  2.   

    this.listView1.SelectedItems.Count > 0
    加个判断
      

  3.   

    可能你的SeletedItems的长度为0,也有可能你的列为0
      

  4.   

    增加this.listView1.SelectedItems.Count > 0判断
    看了数据值不是关键字,subitem[]项
    再请教,this.listView1.SelectedItems.Count > 0加这个判断是为啥?
      

  5.   

    remove也没效果但也不抛异常。int a = ((DataGridViewComboBoxCell)dataGridView.Rows[e.RowIndex].Cells["deName"]).Items.Count;                  
                    if (a > 0)
                    {
                        for (int j = a-1; j >= 0; j--)
                        {
                            try
                            {
                                MessageBox.Show(a.ToString());
                                ((DataGridViewComboBoxCell)dataGridView.Rows[e.RowIndex].Cells["deName"]).Items.RemoveAt(j);
                            }
                            catch(Exception e1)
                            {
                                MessageBox.Show(e1.Message);
                            }
                        }
                    }