c# - 属性更改时未引发 BindingList.ListChanged 事件

标签 c# bindinglist

我有一个 User 类型的 BindingList,User 对象有几个属性(UserName、Password 等)。所以我将事件处理程序绑定(bind)到 BindingList.ListChanged 事件,在添加或删除用户时它工作正常,但是,如果用户属性发生更改,它不会引发事件,有什么办法可以实现这一点?

bindingListUsers.Add(someUser); // This raises ListChangedEvent

bindingListUsers.Delete(someUser); // This raises ListChangedEvent

bindingListUsers[0].UserName = "Another user name"; // This does NOT raise the event

最佳答案

您的用户类型需要实现 INotifyPropertyChanged

关于c# - 属性更改时未引发 BindingList.ListChanged 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/835345/

相关文章:

c# - 如何创建元素自动实例化数组,例如用户自定义类型的int数组?

c# - Web API Core 3.1 ExceptionHandler 中间件在写入 HttpContext.Response 时抛出 'cannot write to closed stream'

C# 动态设计时属性

c# - 如何使用 C# 将格式化的 HTML 字符串复制到剪贴板以进行粘贴?

wpf - 为什么不在 WPF 中使用 BindingList

c# - 如何提高自定义 BindingList 上 AddRange 方法的性能?

c# - 过滤绑定(bind)列表

c# - 聚合 SQL 函数; C# 中的 AVG

c# - 如何创建可比较的图像

c# - BindingList with IList<T> DataSource,元素顺序