473,796 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding - Why Doesnt This Work?

'------------------------------------------------------------------------------------------------
'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 from mLabelFormatsCo llection...

What am I missing?
--
--Eric Cathell, MCSA
Nov 21 '05 #1
2 1602
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 from
mLabelFormatsC 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
Nov 21 '05 #2
Thanks that worked like a charm.....

Didn't think about the currency manager issue since the bindings were
different...

--
--Eric Cathell, MCSA

"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:uU******** ******@tk2msftn gp13.phx.gbl...
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 from
>mLabelFormatsC 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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2186
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
7
2595
by: Vlado Jasovic | last post by:
Hello, I'm using typed dataset for databinding to windows controls and I'm having some problems. I'm trying to move all business logic to datatable column_changing events and the problem that I'm having is when I change some other column, control value doesn't update immediately until I call endcurrentedit on bindingmanager which doesnt happen until user click update button.
2
2663
by: PGP | last post by:
I have a windows form where i bind data to an invisible text box and it doesnt seem to work. I tried with an invalid datamember name and it doesnt even generate an exception till i make the control visible. Is this by design?
4
3318
by: Jason Wolf | last post by:
I have an object which runs in a sperate thread, from the main thread, and while running it updates a public property. In my main form I defined databinding on the property and I would like to see this databinding update my form property to reflect the value of the other components property, but it does not happen. My binding is Databinding.Add("Text",renderEngine,"Framerate"); When the property is initially set, to minus one, the text...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.