Hi Folks

I have a dictionary(Of UInteger, object) that I would like to display some of the properties of the value objects in list form.

Three of the properties are simple text strings. The fourth is a ProgressBar.

I've been thinking that a DataRepeater would be best for this (though I'm not sure, and it could easily be changed at the current stage)

However I have been having trouble understanding how to correctly bind the dictionary to the DataRepeater. I have tried searching Google for some time, but not come across any helpful information.

Firstly, can/should dictionaries be bound to DataRepeaters?

Secondly, if a dictionary is bound to a GUI control will accessing the properties of one of the dictionary's values require invocation? i.e. will the dictionary be tied to the GUI thread?

Thirdly, and most importantly, how should the view be updated when an object is added or removed from the dictionary? From my exceedingly limited understanding of binding, this should happen automatically, yet in my trials so far it is not.

My experiments so far have been to create the dictionary and add one item to it. Bind the dictionary to the DataRepeater (as shown in the code below). Add a button that adds a either adds a second item to the dictionary, or if it has already done that, removes the second item from the dictionary.
I would have expected that when I clicked the button to add a dictionary item, the addition would be shown by listing another item in the DataRepeater, and removed again for a subsequent click... but it does not.

VB Code:
  1. Public Class Test
  2.     Public Shared currentDuts As New Dictionary(Of UInteger, DeviceUnderTest)   ' Collection of all current DUTs.
  3.     Dim bs As New BindingSource
  4.     Dim testTemp As Boolean = False
  5.  
  6.     Private Sub Form1_Load () Handles Me.Load
  7.         '...
  8.         currentDuts.Add(0, New DeviceUnderTest(Me.user, 0))
  9.         currentDuts.Item(0).RackBay = "012345678901"
  10.         currentDuts.Item(0).AssemblySerial = "123456789"
  11.         currentDuts.Item(0).SetProgram(1, "Program1")
  12.  
  13.         bs.DataSource = currentDuts.Values
  14.         LocationLabel.DataBindings.Add("Text", bs, "AssemblySerial")
  15.         DutLabel.DataBindings.Add("Text", bs, "Id")
  16.         ProgramLabel.DataBindings.Add("Text", bs, "Program")
  17.         DutProgress.DataBindings.Add("Value", bs, "Progress")
  18.         DutData.DataSource = bs
  19.         '...
  20.         Me.Show
  21.     End Sub
  22.  
  23.     Private Sub Button1_Click() Handles Button1.Click
  24.         If testTemp = False Then
  25.             currentDuts.Add(1, New DeviceUnderTest(Me.user, 1))
  26.             currentDuts.Item(1).RackBay = "109876543210"
  27.             currentDuts.Item(1).AssemblySerial = "1319A5126"
  28.             currentDuts.Item(1).SetProgram(1, "Program1")
  29.             testTemp = True
  30.         Else
  31.             currentDuts.Remove(1)
  32.             testTemp = False
  33.         End If
  34.     End Sub
  35. End Class