バーコードをスキャンしてログインする登録システムがあります。バーコードには、「*」に続く一意の番号が含まれています。彼らがコードをスキャンすると、リストボックスに入り、テキストボックスから残りをクリアしますが、「 * 」はクリアされません。
何か案は ?ここにコードのチャックがあります:
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))
{
for (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.";
}
}