Hi,
The version is UltraListView.13.2.
I add new item to list say key is "new item" and value is "new value", then remove the item from the list. And the create new item having the same key with deleted item. When I try to add this item to the list, I got the error "Key Already Exists".
In fact, At the beginning, the problem occurred when I tried to add a new item having the key that the list did not contain same key to the list. Before adding step, I broke the application and none of the list items have the same key with the new item.
Thanks for the details. I try to reproduce your scenario with SelectedItem and error message with "Key Already Exists", but without success. I got only error about stack overflow, which is expected for this scenario, but I was not able to reproduce the error with "Key Already Exists". Could you please upload small sample that reproduce your issue and I`ll be glad to research it for you.
Let me know if you have any questions.
Firstly, thank you for your responce.
I think the problem is about Listview's selectedItems. Removing the selected item and then adding the item with the same key causes the problem. There is no problem when removing the checked item not selected.
I use ItemSelectionChanging event to handle some issues,i.e.,
UltraListViewItem selectedItem = List.SelectedItems[0];//guaranteed that only one selected item in the list
selectedItem.Value = someValue;
selectedItem.Key = someKey;
selectedItem.Tag = someTag;
When I remove the selected item from list, ItemSelectionChanging event fires, and the code runs. After remove the selected item, I clear the selection:
List.SelectedItems.Clear();
Unfortunetely, at the end, I got the problem when I try to add the item to list . However, When I comment the lines in the event, everything work fine.
I try to reproduce your issue, using the code below, but everything seems to works properly. If you think that I didn`t reproduce your scenario, feel free to modify my code (or create a small sample) to reproduce the issue. I`ll be glad to research it for you.
// Addnew item
UltraListViewItem it1 = new UltraListViewItem("Test item ", new object[] { "a", "aa", "aaa" });
it1.Key = "new key";
ultraListView1.Items.Add(it1);
// Remove the item
UltraListViewItem it2 = ultraListView1.Items["new key"];
ultraListView1.Items.Remove(it2);
// Add the item with the same key
UltraListViewItem it3 = new UltraListViewItem("Test item ", new object[] { "a", "aa", "aaa" });
it3.Key = "new key";
ultraListView1.Items.Add(it3);
Let me know if you have any questions