c# - InvalidArgument exception on remove of item -
i have listbox1 in items collected.
a timer1 start button1 click.
and progressbar1
here complete code.
private void button1_click(object sender, eventargs e) { timer1.enabled = true; timer1.interval = 500; progressbar1.maximum = listbox1.items.count; } private void timer1_tick(object sender, eventargs e) { x.send("<iq type='set' to='" + textbox6.text + "@conference.jabber.com'>" + "<query xmlns='http://jabber.org/protocol/muc#admin'>" + "<item jid='" + listbox1.items[0].tostring() + "@nimbuzz.com' affiliation='member'/></query></iq>"); listbox1.items.removeat(0); progressbar1.value += 1; groupbox4.text = listbox1.items.count.tostring(); }
the code above runs when 0 item left in listbox1 progressbar1 stops there comes , error
system.argumentoutofrangeexception unhandled message: invalidargument=value of '0' not valid 'index'. parameter name: index
how simple check
if (listbox1.items.count > 0) { listbox1.items.removeat(0); }
Comments
Post a Comment