C# Array not clearing in listbox -
i'm new programming, , have trouble clearing listbox how want. happens user able enter value, , stored array, added listbox. user can clear both array/listbox @ anytime. after entering value e.g. 123 , being displayed on listbox, using clear button. again entering value e.g. 555, instead of 555 being first number in lisbox is: 0, 155. if again clear add number e.g. 1123, output is: 0, 0, 1123. etc. seem have cleared previous elements , placing number next index. how empty array/listbox add numbers first index , not 0000...n displaying in listbox.
button clear:
private void btnclear_click(object sender, eventargs e) { array.clear(numarray, 0, numarray.length); lstholdvalue.items.clear(); }
the issue may not resetting index value 0 when clear clicked. think in code clears numarray, setting values 0 or creating array, remember index still whatever before clearing. if not post clearing code , can help.
i saw clearing code , reason. add clear code:
this.index = 0;
Comments
Post a Comment