9
我有一个数据网格加载行事件检查事件已经存在
_gridObj.LoadingRow += new EventHandler<DataGridRowEventArgs>(_gridObj_LoadingRow);
,并在处理程序中,我创建另一个事件。在下面的代码中,我怎么知道该行的MouseLeftBtn事件是否已经存在?
void _gridObj_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.MouseLeftButtonUp += new MouseButtonEventHandler(Row_MouseLeftButtonUp);
}
感谢,
巫毒
您是否想测试一个事件处理程序是否已附加,以便您不附加多个事件?即LoadingRow事件可能每行被触发多次? – aqwert 2010-09-27 01:11:17
是的,在_gridObj_LoadingRow中,MouseLeftButtonUp事件连接多次。我想检查'MouseLeftButtonUp'事件是否已经连接,所以我没有为它注册其他事件。它在这里多次触发'MouseLeftButtonUp'。 – VoodooChild 2010-09-27 03:26:23
好吧,我已经添加了一个应该满足您的要求的答案。 – aqwert 2010-09-27 04:39:15