RobstaMeade
New member
- Joined
- Aug 3, 2011
- Messages
- 4
- Programming Experience
- 10+
Hi,
I have a custom collection which is derived from a base class implementing IEnumerable and IEnumerator, this collection is populated with custom objects.
I'm trying to set the datasource on a ComboBox on a WinForm to use the above collection - but when the code is run the ComboBox is always empty.
The code I was using was this:
As I couldn't get that to work, I tried this:
Any information/help is appreciated,
Regards
Rob
I have a custom collection which is derived from a base class implementing IEnumerable and IEnumerator, this collection is populated with custom objects.
I'm trying to set the datasource on a ComboBox on a WinForm to use the above collection - but when the code is run the ComboBox is always empty.
The code I was using was this:
Private Sub ViewSources_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' declaration
Dim sourceCollection As SourceCollection
Dim source As Source
' instantiate
sourceCollection = sourceCollection.GetSources
ViewSources_Source_ComboBox.DataSource = sourceCollection
ViewSources_Source_ComboBox.DisplayMember = "Name"
ViewSources_Source_ComboBox.ValueMember = "Name"
' housekeeping
HouseKeeping.Dispose(sourceCollection)
End Sub
As I couldn't get that to work, I tried this:
Can anyone explain to me why the first chunk of code didn't work? I tend to do more coding with web than windows and I'm pretty sure I've used the first code example on a DropDownList control previously and its worked?Private Sub ViewSources_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' declaration
Dim sourceCollection As SourceCollection
Dim source As Source
' instantiate
sourceCollection = sourceCollection.GetSources
For Each source In sourceCollection
ViewSources_Source_ComboBox.Items.Add(source)
Next
ViewSources_Source_ComboBox.DisplayMember = "Name"
ViewSources_Source_ComboBox.ValueMember = "Name"
' housekeeping
HouseKeeping.Dispose(sourceCollection)
End Sub
Any information/help is appreciated,
Regards
Rob
Last edited: