|
-
Aug 22nd, 2013, 08:35 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Help getting started with DataRepeater
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:
Public Class Test Public Shared currentDuts As New Dictionary(Of UInteger, DeviceUnderTest) ' Collection of all current DUTs. Dim bs As New BindingSource Dim testTemp As Boolean = False Private Sub Form1_Load () Handles Me.Load '... currentDuts.Add(0, New DeviceUnderTest(Me.user, 0)) currentDuts.Item(0).RackBay = "012345678901" currentDuts.Item(0).AssemblySerial = "123456789" currentDuts.Item(0).SetProgram(1, "Program1") bs.DataSource = currentDuts.Values LocationLabel.DataBindings.Add("Text", bs, "AssemblySerial") DutLabel.DataBindings.Add("Text", bs, "Id") ProgramLabel.DataBindings.Add("Text", bs, "Program") DutProgress.DataBindings.Add("Value", bs, "Progress") DutData.DataSource = bs '... Me.Show End Sub Private Sub Button1_Click() Handles Button1.Click If testTemp = False Then currentDuts.Add(1, New DeviceUnderTest(Me.user, 1)) currentDuts.Item(1).RackBay = "109876543210" currentDuts.Item(1).AssemblySerial = "1319A5126" currentDuts.Item(1).SetProgram(1, "Program1") testTemp = True Else currentDuts.Remove(1) testTemp = False End If End Sub End Class
Thanks 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|