【发布时间】:2021-10-01 15:27:38
【问题描述】:
我正在尝试制作一个从 USB 扫描仪扫描条形码的应用程序。该应用程序应该寻找与条形码中的代码相对应的工作。我目前的问题是,当我尝试使用该应用程序时,它只需要 1 个字符并尝试查找与该字符对应的作业,而不是让我输入整个字符串并按 Enter。
这是我的代码:
public void SearchJob(object sender, EventArgs e)
{
this.ChangeCurrentEntity(this.Manager.GetEntity(j => j.Code == this.TypedView.BarcodeNumber)?.FirstOrDefault());
this.LoadView();
if (this.confirmation.GetConfirmation())
{
var tokenSource = new CancellationTokenSource();
this.task = Task.Run(() => { }, tokenSource.Token);
if (!task.IsCompleted)
tokenSource.Cancel();
if (dcConfig.CancelCode == "CancelCode")
{
this.Host.CloseHost();
}
}
this.TypedView.BarcodeNumber = "";
}
getConfirmation() 是确认工作的弹出窗口,我认为目前与我的问题无关。
这是我的表格:
private void JobNumberTextBox_TextChanged(object sender, EventArgs e)
{
JobEntered?.Invoke(this, e);
}
任何帮助将不胜感激。
【问题讨论】:
标签: c# barcode barcode-scanner