Hi, A bunch of dotnet framework components use a DataSource component. I have an object that has a number of settings that can modify the DataSource which it represents. I would like to set this object as the dropdown DataSource of a set of ComboBoxes and DataGridViewComboBoxCells.
My problem comes when trying to actually hook the thing into the ComboBox. I guess that because the changes to the DataSource can happen once the DataSource has been set, I have to use one of these BindingSource things, but the MSDN literature is pulling its usual prank of telling me what a bindingSource is without telling me what it does or how it works.
What's the best way you guys can suggest of hooking this Object up as a DataSource/BindingSource?
EDIT:
Obviously this class is junk, but it illustrates the sort of object I have now.
Most of the timing is up in the air at the moment, but basically what this shows is that my class is not a collection itself, but contains one. I need to be able to instruct the DataSource property of a ComboBox that there is a volatile list to be found here, and that it should use that list as the DataSource for its dropdown.
Public Class DynamicDataSource
Private basicList As New List(Of String)(New String() {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"})
Private _showEvensOnly As Boolean
Private _showNotContainingO As Boolean
Public Property ShowEvensOnly() As Boolean
Get
Return _showEvensOnly
End Get
Set(ByVal value As Boolean)
_showEvensOnly = value
End Set
End Property
Public Property ShowNotContainingO() As Boolean
Get
Return _showNotContainingO
End Get
Set(ByVal value As Boolean)
_showNotContainingO = value
End Set
End Property
Public Function GetDynamicList() As List(Of String)
Dim processMe As New List(Of String)(basicList)
If Me._showEvensOnly Then
For JJ As Integer = processMe.Count - 1 To 0 Step -1
If JJ Mod 2 = 0 Then
processMe.Remove(processMe(JJ))
End If
Next
End If
If Me._showNotContainingO Then
For JJ As Integer = processMe.Count - 1 To 0 Step -1
If processMe(JJ).ToUpper.Contains("O"c) Then
processMe.Remove(processMe(JJ))
End If
Next
End If
Return processMe
End Function
End Class