views:

34

answers:

2

I have both a ListBox (AlarmBox) and a ListView (listView1). They both save into 2 different Properties.Settings (AlarmList and AlarmList2).

Properties.Settings.Default.AlarmList.Remove(AlarmList.SelectedItem);
Properties.Settings.Default.AlarmList2.Remove(listView1.SelectedItems);
AlarmList.Items.RemoveAt(AlarmList.SelectedIndices[0]);
listView1.Items.RemoveAt(listView1.SelectedIndices[0]);

That's the code for the remove button, but since listView1 doesn't have a SelectedItem function, I resorted to using SelectedItems.

When removing an item from both boxes, AlarmBox removes the values correctly from both the application and the settings, but when removing from listView1, the value is only removed from the app, but isn't removed from the settings.

EDIT: Also, when replacing listView1.SelectedItems with AlarmList.SelectedItem, it removes correctly.

A: 

Have you tried

.Remove(listView1.SelectedItems[0]);

OK, then how about trying the RemoveAt with the index?

.RemoveAt(listView1.SelectedItems[0].Index);
astander
Just tried it. Doesn't work.
Kevin
2nd one works. Thanks!
Kevin
A: 
CMH