0

Why does the following code gives me only one row with text "3" after 5 seconds?

        var data = new Dictionary<string, Foo>();
        data.Add("foo", new Foo { bar = "1" });

        Invoke((MethodInvoker)delegate()
        {
            listBox.DataSource = new BindingSource(data, null);
            listBox.DisplayMember = "Value";
            listBox.ValueMember = "Key";
        });

        Thread.Sleep(5000);

        data["foo"].bar = "3";
        data.Add("bar", new Foo { bar = "2" });

        Invoke((MethodInvoker)delegate()
        {
            listBox.DisplayMember = "";
            listBox.DisplayMember = "Value";
        });

How can I display all elements and their changes correctly?

None of the suggested solutions from here helped me.

Community
  • 1
  • 1
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242

0 Answers0