sql - C# Textbox enters info but leaves a ' * ' in textbox -
i have registration system, people scan barcodes , logs them in. barcodes hold unique number following '*'. when scan code enters listbox , clears remainder out of textbox, but, not clearing ' * '.
any ideas ? here chuck of code:
private void textbox1_keyup(object sender, keypresseventargs e) { object returnvalue; string txtend = textbox1.text; returnvalue = textbox1.text.replace(@"*", ""); if (e.keychar != '*') return; { if (listbox1.items.contains(returnvalue)) { (int n = listbox1.items.count - 1; n >= 0; --n) { string removelistitem = returnvalue.tostring(); if (listbox1.items[n].tostring().contains(removelistitem)) { //listbox1.items.removeat(n); } } } else listbox1.items.add(returnvalue); textbox1.clear(); system.io.streamwriter sw = new system.io.streamwriter(fullfilename); foreach (object item in listbox1.items) sw.writeline(item.tostring()); sw.flush(); sw.close(); if (listbox1.items.count != 0) { disableclosebutton(); } else { enableclosebutton(); } label6.text = "currently " + listbox1.items.count.tostring() + " in attendance."; } }
after rereading question understood after processing '*' inserted empty textbox.
to stop handling of key event use statement:
e.handled = true;
this indicated event handled code , should not processed further.
Comments
Post a Comment