2

使用 ListView 控件在 MouseDoubleClick_event 上将行添加到 DataGridView 行正在添加到 DataGrid 但它也添加了重复行。有没有办法处理重复值

   ArrayList arrListChkIDs = new ArrayList();
        if (dgvPriceView.Rows.Count > 0)
        {
            for (int i = 0; i < dgvPriceView.Rows.Count - 1; i++)
            {
                arrListChkIDs.Add(dgvPriceView.Rows[i].Cells["Code"].Value);
            }

        }

获取数组列表中的唯一值以与我的 ListView 值进行比较现在我应该如何比较它?

4

1 回答 1

3

嘿,现在从这里开始很简单

ArrayList arrListChkIDs = new ArrayList();
//Now Get and Check The Code from List View or put the Index Number  at subItems
string Code = listView.SelectedItems[0].SubItems["Code"].Text;
if (!arrListChkIDs.Contains(Code))
{

}
else
{
    MessageBox.Show("Row Already Exist!",
                    MessageBoxButtons.OK, 
                    MessageBoxIcon.Error);
    return;
}
于 2013-03-12T07:42:43.770 回答