问题标签 [listchanged]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
547 浏览

wpf - DataGrid 中的对象未在它们所在的 BindingList 中触发 ListChanged 事件

我已经阅读了几乎所有关于 Stackoverflow 的问题DataGrid, BindingList<T>ListChanged但仍然没有答案。

我有一个名为 的对象Invoice : INotifyPropertyChanged,它有一个BindingList<InvoiceLine> : INotifyPropertyChanged由多个对象组成的InvoiceLine : INotifyPropertyChanged对象。

现在,当在DataGrid绑定到的时,我更改了一个事件BindableList<InvoiceLine>的属性之一,但事件没有在.InvoiceLinePropertyChangedListChangedBindableList<InvoiceLine>

InvoiceLines 的初始化如下:

0 投票
1 回答
799 浏览

bindinglist - BindingList ListChanged 事件

我正在订阅绑定列表中的 ListChanged 事件。当列表更改(添加/删除项目)时,我将更新内部列表。内部列表包含与原始列表中的项目1-1 对应的对象。项目顺序可以不同。

根据文档,触发事件时,ListChangedEventArgs.ListChangedType 可以是以下之一:ItemAdded、ItemDeleted、Reset 和 ItemChanged。当列表中的项目发生更改时,ListChangedType 为 ItemChanged,该项目被另一个项目替换,或者其属性之一被修改。

我如何区分这些情况,以便如果列表中的项目被另一个项目替换,我可以重新加载内部列表,但如果是属性更改则什么都不做?

有没有更好的方法来实现这一点?

0 投票
1 回答
401 浏览

c# - 将行添加到源表时不会触发 DataView.ListChanged 事件

在某些情况下,当我向表中添加新行时,它不会触发 ListChanged 事件。奇怪的是,更新和删除行确实会触发该事件。

0 投票
0 回答
149 浏览

refresh - 多次设置 RaiseListChangedEvent 属性的性能问题

在刷新控件之前,我将其 bindingsource 的 RaiseListChangedEvent 属性设置为 false,然后在刷新后将其再次设置为 true 并将 ResetBindings 设置为 false。

如果场景是这样的:

它会导致任何性能问题吗?

0 投票
0 回答
392 浏览

vb.net - ListChanged 事件未触发?

我有一堂课bindinglist(of T)bindinglist绑定到我的datagridview表单上。将项目添加到 时bindinglist,它们会显示在 中,datagridview但是scrollbar永远不会更改以适应新数据。我开始认为这是因为Listchanged事件没有被触发(或被我的表单正确捕获)。我的代码设置如下:

数据类:

数据生成器类:

形式:

我知道有很多代码,但我想清楚。因此,当我单击开始按钮时,新项目开始出现,但是,一旦它们到达网格的底部,滚动条就不会出现。如果我单击更改格式按钮,数据会更改格式并正确更新网格。我的印象是该ListChanged事件会自动与 abindinglist和一起使用datagridview。我尝试调用 update 和 refresh onmyDataGridView并设置datagridview.datasource为空,然后返回DataList.

我错过了什么吗?

0 投票
1 回答
379 浏览

javafx-8 - JavaFX ListChangedListeners 不使用 ControlsFX PopOver 和 CheckListView 触发

我正在编写一个通用 Java 类来显示可以取消/选中的过滤器项目列表,然后将结果选择传递给控制器​​以过滤主要对象的集合以进行显示。我正在使用两个 ControlsFX 控件:PopOver包含过滤器列表的控件和CheckListView显示和控制单个项目的控件。

流程是PopOver在控制器的构造函数中实例化过滤器类,并且每次显示时重新加载源数据。

从表面上看,代码似乎可以工作。添加了源项目,选中和取消选中工作并且选中项目列表中的项目数正确。但是,我已将侦听器添加到源数据和检查项目列表的可观察列表中,并且两者都没有被触发。

我尝试将侦听器内联并作为单独的方法(如示例中所示)编写,并且尝试以传统onChanged和 lambda 样式编写它们。两者都没有改变。我也尝试过使用几乎相同的代码,只是将CheckListView用作窗格的节点。这确实按预期工作。

我还浏览了 ControlsFX 问题日志,没有发现任何直接相关的内容(除了确认我使用的代码似乎没问题)。

这是过滤器类:

这是测试存根:

0 投票
0 回答
210 浏览

c# - C# subclassing BindingList, ListChanged fires outside of class, but not inside class

I'm trying to wrap my head around how BindingList works in a dummy project. The eventual goal is [Microsoft.VisualBasic.PowerPacks.DataRepeater]->[BindingList of POCOs that are backed by Dapper/SQL Server Compact and automagically do CRUD on ListChanged] (as opposed to [DataRepeater]->[DataTable]; please DO leave feedback on validity of this approach in the comments).

My rationale for Add()'ing records in the dummycollection constructor was that it should SELECT existing records from the db at the time of its birth.

The specific question of the moment is: Why does Add()'ing behave differently on the inside versus the outside? My expectation is that the ListChanged event should fire in both cases, but it doesn't. I'm sure I'm missing something simple.

Outside:

Inside:

Furthermore, the "insider" record behaves strangely compared to the "outsider" record. When I put a DataGridView on my form for troubleshooting, and edit dummytext in the repeater and grid, visible updates between the two are sporadic or unpredictable when clicking around the various controls. The "outsider" record visibly updates more consistently.

0 投票
0 回答
198 浏览

c# - 即使 DataRow 的属性值未修改,DataView.ListChanged 事件也未正确触发

我有一个 DataTable,并且我已经为我的更改侦听了DataTable.DefaultView.ListChanged事件,并且在数据更新时,ListChanged 事件在更新现有 DataRow 的相同值时被不正确地触发。

在这里,在使用相同值更新 DataRow 时,ListChanged 事件会通过ListChangedType.ItemChanged触发。但我相信只有在 DataRow 的任何属性被修改时才应该触发该事件。