Hello Dominique,
Hi Jared,
is it possible that you post your "couple of helper functions" ? (i
have also the same need)
Here's the basic class that I use. It accepts any kind of list as the data
source. ReloadFromDataSource needs to be called whenever the list changes
unless the collection is an IBindingList. In that case it will auto update.
Imports System.ComponentModel
Public Class DropDownBinding
Private m_dd As ToolStripDropDown
Private m_list As IEnumerable
Private m_bindingList As IBindingList
Public Sub New(ByVal dd As ToolStripDropDown)
m_dd = dd
m_list = New List(Of Object)()
End Sub
Public Sub SetDataSource(ByVal e As IEnumerable)
If Not m_bindingList Is Nothing Then
RemoveHandler m_bindingList.ListChanged, New ListChangedEventHandler(AddressOf
Me.OnListChanged)
End If
m_bindingList = TryCast(e, IBindingList)
m_list = e
If Not m_bindingList Is Nothing Then
AddHandler m_bindingList.ListChanged, New ListChangedEventHandler(AddressOf
Me.OnListChanged)
End If
RebuildList()
End Sub
Public Sub ReloadFromSource()
RebuildList()
End Sub
Private Sub OnListChanged(ByVal sender As Object, ByVal e As ListChangedEventArgs)
RebuildList()
End Sub
Private Sub RebuildList()
m_dd.Items.Clear()
For Each cur As Object In m_list
m_dd.Items.Add(cur.ToString())
Next
End Sub
End Class
--
Jared Parsons [MSFT]
(e-mail address removed)
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights.