由于我从数据库加载数据并将其放入 FormLoad 上的 DevExpress TextEdit 控件中,因此调用了事件处理程序 TextEdit_EditValueChanged。是否可以在事件处理程序中进行任何检查,或防止引发事件?
问问题
3372 次
2 回答
4
像这样的东西:
bool dataLoaded = false;
private void LoadData()
{
// do the loading and set the Text property of the textEdit
dataLoaded = true;
}
private void TextEdit_EditValueChanged(object sender, EventArgs e)
{
if (dataLoaded == false) return;
// the code after this comment will run only after the data was loaded
}
或者您可以在加载完成后添加事件处理程序,如下所示:
private void LoadData()
{
// do the loading and set the Text property of the textEdit
TextEdit.EditValueChanged += TextEdit_EditValueChanged;
}
private void TextEdit_EditValueChanged(object sender, EventArgs e)
{
// the code after this comment will run only after the data was loaded
}
于 2012-08-14T16:10:01.923 回答
-1
使用属性
private void TextEdit_EditValueChanged(object sender, EventArgs e)
{
if (!this.IsLoaded) return;
// the code after this comment will run only after the data was loaded
}
于 2017-01-12T12:17:37.053 回答