private void DeleteSelectedMember() { if (lstMembers.SelectedItems.Count > 0) { ListViewItem item = lstMembers.SelectedItems[0]; int index = item.Index; if (item.Tag is Field) { attributeCount--; } parent.RemoveMember(item.Tag as Member); lstMembers.Items.Remove(item); Changed = true; int count = lstMembers.Items.Count; if (count > 0) { if (index >= count) { index = count - 1; } lstMembers.Items[index].Selected = true; } else { DisableFields(); } } }