We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在UcDataGridView控件中,当使用了自定义单元格,并加入按钮后,删除对应的行后,使用ReloadSource函数重新加载控件时,会导致用户控件消息处理函数重复加载,导致多次触发,代码如下
源代码UCDataGridViewRow.cs 193行-201行 foreach (Control item in this.panCells.Controls) { if (item is IDataGridViewCustomCell) { IDataGridViewCustomCell cell = item as IDataGridViewCustomCell; //此处消息处理链未被清空,导致重复加载 cell.RowCustomEvent += cell_RowCustomEvent; cell.SetBindSource(DataSource); } }
改为如下代码,貌似解决了这个问题
// 获取事件信息 EventInfo eventInfo = cell.GetType().GetEvent("RowCustomEvent"); // 如果事件存在 if (eventInfo != null) { // 获取字段,该字段包含了已订阅的委托 FieldInfo fieldInfo = cell.GetType().GetField("RowCustomEvent", BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo != null) { // 获取已订阅的委托 MulticastDelegate multicastDelegate = fieldInfo.GetValue(cell) as MulticastDelegate; if (multicastDelegate != null) { // 逐个取消订阅已订阅的委托 foreach (Delegate handler in multicastDelegate.GetInvocationList()) { eventInfo.RemoveEventHandler(cell, handler); } } } } cell.RowCustomEvent += cell_RowCustomEvent; cell.SetBindSource(DataSource);
The text was updated successfully, but these errors were encountered:
确实有这个BUG,也发现了
Sorry, something went wrong.
cell.RowCustomEvent -= cell_RowCustomEvent; cell.RowCustomEvent += cell_RowCustomEvent; 最简单的方法,先减一次再加一次,这样就不重复了
No branches or pull requests
在UcDataGridView控件中,当使用了自定义单元格,并加入按钮后,删除对应的行后,使用ReloadSource函数重新加载控件时,会导致用户控件消息处理函数重复加载,导致多次触发,代码如下
源代码UCDataGridViewRow.cs 193行-201行
foreach (Control item in this.panCells.Controls)
{
if (item is IDataGridViewCustomCell)
{
IDataGridViewCustomCell cell = item as IDataGridViewCustomCell;
//此处消息处理链未被清空,导致重复加载
cell.RowCustomEvent += cell_RowCustomEvent;
cell.SetBindSource(DataSource);
}
}
改为如下代码,貌似解决了这个问题
The text was updated successfully, but these errors were encountered: