Now I know how to delete an Item from the listView, but I want the item before the deleted item to become automatically selected.
Eg:
item1 item2 item3 <-- delete this one, and "item2" item becomes selected, ect..
Here's what I have so far:
if (officeView.Items.Count != 0 && officeView.Items.Count > 1)
{
int index = officeView.FocusedItem.Index;
officeView.Items.Remove(officeView.Items[index]);
officeView.Items[index-1].Selected = true;
}
else if (officeView.Items.Count == 1)
{
int index = officeView.FocusedItem.Index;
officeView.Items.Remove(officeView.Items[index]);
officeView.Items[0].Selected = true;
}
When i run it, and try to delete things it works fine the first time but then goes bad.
Eg I have this:
item1 item2 item3 item4 item5I select "item3" press delete, and it deletes it. Now item2 is automatically selected. I then press delete again, and item4(which is now in item3s position) is deleted. See the problem? Im really not sure why its doing that, maybe Im missing something simple.
Any help is appreciated ~ Committed. :)


Sign In
Create Account


Back to top









