0
我有一个文本框,其中其Leave事件是这样的:时间我需要这个事件如何控制异步事件文本
private async void TxtLotTextLeave(object sender, EventArgs e)
{
if (!isChecked)
{
isChecked = true;
var mylength = BarcodeUtil.LotStripZeroes(txtLot.Text.Trim()).Length;
var strippedLot = BarcodeUtil.LotStripZeroes(txtLot.Text.Trim());
if (mylength > 0)
{
if (mylength.Between(16, 18) &&
(strippedLot.StartsWith(AppState.LotOldStandardDigits) ||
strippedLot.StartsWith(AppState.LotStandardDigits)))
{
await GetLotData();
}
else
{
ShowAppMessage(AppMessages["WrongLot"], 0, Color.Black, Color.BlanchedAlmond);
txtLot.Text = "";
LotFocus(true);
}
}
}
}
99%喜欢这个工作。
但我只需要当一个特定的按钮点击不发射它。
按钮点击:
private void BtnClearClick(object sender, EventArgs e)
{
ClearForm();
LotFocus(true);
}
我尝试了明显的使用全局布尔变量,并将其设置为false click事件,并检查它在产假,但它不具有做work..I嫌疑人与异步?
附加信息:
了我所是创建一个布尔变量needTxtValidation
并尝试将其设置为在不同的地方,如按一下按钮,文本框,按键,鼠标按下按钮假的,但它没有工作。
发布你的尝试与布尔标志,应该工作。而且AFAIK没有干净的方式去做你想做的事情。另外,哪个UI框架? Winforms或..? – 2014-12-05 06:57:47
我也可以使用一个肮脏的... – e4rthdog 2014-12-05 07:00:24