Hi,
"ECathell" <ec******@nospa m.com> wrote in message
news:uJ******** ******@TK2MSFTN GP09.phx.gbl...
'------------------------------------------------------------------------------------------------
'Label Formats
'------------------------------------------------------------------------------------------------
Me.cboLabelForm at1.DataSource = mLabelFormatsCo llection
Me.cboLabelForm at1.DisplayMemb er = "FormatName "
Me.cboLabelForm at1.DataBinding s.Add(New Binding("Text",
mProductCollect ion, "Formatname 1"))
Me.cboLabelForm at2.DataSource = mLabelFormatsCo llection
Me.cboLabelForm at2.DisplayMemb er = "FormatName "
Me.cboLabelForm at2.DataBinding s.Add(New Binding("Text",
mProductCollect ion, "Formatname 2"))
The databinding works, but the controls display the same information
depending on which the first bindings are >bound. FormatName1 and
FormatName2 can have different values, but both values come frommLabelFormatsC ollection...
What am I missing?
When you bind different Controls to the same DataSource then they navigate
together because they share a CurrencyManager (mantains position).
Bind each ComboBox to a different instance (copy) of the FormatCollectio n.
--- Or create a simple wrapper class, this way the external binding (all
that matters) uses a different instance while internally the same list is
used.
Public Class ListWrapper
Implements IListSource
Private _list As IList
Public Sub New(ByVal List As IList)
_list = List
End Sub
Public ReadOnly Property ContainsListCol lection() As Boolean _
Implements System.Componen tModel.IListSou rce.ContainsLis tCollection
Get
Return False
End Get
End Property
Public Function GetList() As System.Collecti ons.IList _
Implements System.Componen tModel.IListSou rce.GetList
Return _list
End Function
End Class
Then use it like :
ComboBox1.DataS ource = New ListWrapper( mLabelFormatsCo llection )
ComboBox2.DataS ource = New ListWrapper( mLabelFormatsCo llection )
....
If you use NET2.0 you could do:
ComboBox1.DataS ource = New BindingSource( mLabelFormatsCo llection, "" )
ComboBox2.DataS ource = New BindingSource( mLabelFormatsCo llection, "" )
HTH,
Greetings
--
--Eric Cathell, MCSA