BindingList <T> dictionary equivalent in WinForms

In WinForms you can associate a dictionary through BindingSourcewith a ListBox

Dictionary<string, GraphApiFunction> myDictionary = new Dictionary<string, GraphApiFunction>();

listBox1.DataSource = new BindingSource(myDictionary, null);
listBox1.DisplayMember = "Key";
listBox1.ValueMember = "Value";

However, changes after installing DataSource myDictionarycannot be detected, and therefore the ListBox is not updated. For lists, there is a special BindingSource called a BindableList

var myBindableList = new BindingList<string>();
listBox1.DataSource = myBindableList;

My question

  • is there any equivalent BindingList<T>for aDictionary
  • or are there other ways to update the ListBox (without resetting DataSourcewith every change)?
+4
source share

Source: https://habr.com/ru/post/1692369/


All Articles