I have this code, behold:
string message = "Are you sure? You will lose this
customer forever. (Well you'll have re-create from
scratch)";
string caption = "Delete";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = MessageBox.Show(this, message, caption, buttons);
if(result == DialogResult.Yes)
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
Customer c = (Customer)lvi.Tag;
alCustomers.Remove(c);
//this.lstCustomers.Items.Remove(lvi);
break;
}
}
}
if(alCustomers.Count<1)
{
this.tabCustomers.Visible = false;
}
Okay what this code does is delete the selected customer
(the one with image an image index of 1) removes the
ListViewItem from the listview then checks to see if there
are no customers left in the array list, if not it hides a
tab control.
What is entertaining is that if you go through this code
with the debugger and remove the slashed out line (where i
remove the listviewitem) alCustomers will never have a
count of zero.
It will for a little while until it hits the slashed out
line, at that point it regains the customer it previously
removed.
Anyone got any ideas why? (I'm assuming it's something to
do with the tag??)
Any help, as always, greatly appreciated, many smiles and
thanks to repliers.
jax