473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stop default currency manager behavior?

Hi,

Let's say I have one datatable, that I want to use as the datasource for 2
dropdowns. So both are bound to the same one.

But now, when I select a row in dropdown A, the selected row in dropdown B
changes to the same thing! Each dropdown represents a different column in
the main record - they just happen to have the same options for their valid
values.

This behavior of the currency manager is very undesirable. I want both
dropdowns to have the same source - so if the values in the dropdown are
modified behind the scenes, that both dropdown receive notifications of
new/deleted/updated rows.

However, I want the whole concept of a 'current' row that is provided with
all the currency manager stuff to go away.

Is this possible? Or do I need to have 2 copies of the data for the
dropdown option values?
Jul 21 '05 #1
6 1783
Marina wrote:
Hi,

Let's say I have one datatable, that I want to use as the datasource for 2
dropdowns. So both are bound to the same one.

But now, when I select a row in dropdown A, the selected row in dropdown B
changes to the same thing! Each dropdown represents a different column in
the main record - they just happen to have the same options for their valid
values.

This behavior of the currency manager is very undesirable. I want both
dropdowns to have the same source - so if the values in the dropdown are
modified behind the scenes, that both dropdown receive notifications of
new/deleted/updated rows.

However, I want the whole concept of a 'current' row that is provided with
all the currency manager stuff to go away.

Is this possible? Or do I need to have 2 copies of the data for the
dropdown option values?


You need to explicitly create multiple binding contexts, one for each
drop-down. Each data source used in data binding is assigned it's own
binding context. Unfortunately, the form itself only has one binding
context, so by default, all controls on a form that are bound to a given
source have the same context.

To get around this problem, each set of controls you want to have it's
own context needs to be in it's own container, like a group box. At
run-time you simply assign a new BindingContext() to the BindingContext
property of each container, and those containers will no longer be
synchronized.

--Mike

Jul 21 '05 #2
Found solution: Initialize the BindingContext of each dropdown to a new
BindingContext prior to setting the datasource.

"Marina" <so*****@nospam.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
Hi,

Let's say I have one datatable, that I want to use as the datasource for 2
dropdowns. So both are bound to the same one.

But now, when I select a row in dropdown A, the selected row in dropdown B
changes to the same thing! Each dropdown represents a different column in
the main record - they just happen to have the same options for their valid values.

This behavior of the currency manager is very undesirable. I want both
dropdowns to have the same source - so if the values in the dropdown are
modified behind the scenes, that both dropdown receive notifications of
new/deleted/updated rows.

However, I want the whole concept of a 'current' row that is provided with
all the currency manager stuff to go away.

Is this possible? Or do I need to have 2 copies of the data for the
dropdown option values?

Jul 21 '05 #3
That's what I ended up doing.

However, the problem is that the Value property for the dropdown is bound to
a row in the current record being edited. If the dropdown has a new binding
context, now when a record is selected in the grid (listed of records to
edit), the dropdown no longer has its value property correctly bound to the
current record. Where as before when it was using 1 bindingcontext, this
worked correctly.

So it seems I can have one or the other... but not both at the samet ime.

"Mike Edenfield" <ku****@not.kutulu.not.org> wrote in message
news:ue**************@TK2MSFTNGP14.phx.gbl...
Marina wrote:
Hi,

Let's say I have one datatable, that I want to use as the datasource for 2 dropdowns. So both are bound to the same one.

But now, when I select a row in dropdown A, the selected row in dropdown B changes to the same thing! Each dropdown represents a different column in the main record - they just happen to have the same options for their valid values.

This behavior of the currency manager is very undesirable. I want both
dropdowns to have the same source - so if the values in the dropdown are
modified behind the scenes, that both dropdown receive notifications of
new/deleted/updated rows.

However, I want the whole concept of a 'current' row that is provided with all the currency manager stuff to go away.

Is this possible? Or do I need to have 2 copies of the data for the
dropdown option values?


You need to explicitly create multiple binding contexts, one for each
drop-down. Each data source used in data binding is assigned it's own
binding context. Unfortunately, the form itself only has one binding
context, so by default, all controls on a form that are bound to a given
source have the same context.

To get around this problem, each set of controls you want to have it's
own context needs to be in it's own container, like a group box. At
run-time you simply assign a new BindingContext() to the BindingContext
property of each container, and those containers will no longer be
synchronized.

--Mike

Jul 21 '05 #4
Marina wrote:
That's what I ended up doing.

However, the problem is that the Value property for the dropdown is bound to
a row in the current record being edited. If the dropdown has a new binding
context, now when a record is selected in the grid (listed of records to
edit), the dropdown no longer has its value property correctly bound to the
current record. Where as before when it was using 1 bindingcontext, this
worked correctly.


I realized this as soon as my message came back to me :( Essentially
your problem is that you want identical binding contexts for the data
source behind the Value property, but different binding contexts for the
data source behind the items themselves.

One possibility I can think of is to wrap your drop-downs (and other
controls, even) into a user control. Define two properties and update
the .Value of each drop-down in the property's set method. These
properties could be bound to the form's data source, thus use a single
binding context, while internally you could have any number of other
binding contexts. Somehow this seems like overkill but I can't come up
with anything better off the top of my head.

--Mike
Jul 21 '05 #5
This is a very interesting solution. In fact, the dropdown are already
wrapped up in user controls for the purposes of being able to swap them in
and out if we go with a different vendor for the dropdown, so I'm half way
there.

Great suggestion, I'll give it a shot.

"Mike Edenfield" <ku****@not.kutulu.not.org> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
Marina wrote:
That's what I ended up doing.

However, the problem is that the Value property for the dropdown is bound to a row in the current record being edited. If the dropdown has a new binding context, now when a record is selected in the grid (listed of records to
edit), the dropdown no longer has its value property correctly bound to the current record. Where as before when it was using 1 bindingcontext, this worked correctly.


I realized this as soon as my message came back to me :( Essentially
your problem is that you want identical binding contexts for the data
source behind the Value property, but different binding contexts for the
data source behind the items themselves.

One possibility I can think of is to wrap your drop-downs (and other
controls, even) into a user control. Define two properties and update
the .Value of each drop-down in the property's set method. These
properties could be bound to the form's data source, thus use a single
binding context, while internally you could have any number of other
binding contexts. Somehow this seems like overkill but I can't come up
with anything better off the top of my head.

--Mike

Jul 21 '05 #6
Use a seperate bindingcontext
"Marina" <so*****@nospam.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
Hi,

Let's say I have one datatable, that I want to use as the datasource for 2
dropdowns. So both are bound to the same one.

But now, when I select a row in dropdown A, the selected row in dropdown B
changes to the same thing! Each dropdown represents a different column in
the main record - they just happen to have the same options for their valid values.

This behavior of the currency manager is very undesirable. I want both
dropdowns to have the same source - so if the values in the dropdown are
modified behind the scenes, that both dropdown receive notifications of
new/deleted/updated rows.

However, I want the whole concept of a 'current' row that is provided with
all the currency manager stuff to go away.

Is this possible? Or do I need to have 2 copies of the data for the
dropdown option values?

Jul 21 '05 #7

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

Similar topics

4
by: Niel | last post by:
Hello friends, I think this issue has been posted before but i have not been able to get any solution that is why i am posting it again in detail as to what exactly is happneing in my case. Hope...
12
by: Ramesh | last post by:
Hi, Pls. answer to this question? Does the position change of the currency manager affect the Dataset. Since I wanted to use the HasChanges method of the dataset to check whether is there any...
5
by: Manuel Canas | last post by:
Hi there, I have a form with a couple of tabs on in and I'm filling the form from a dataset with the fill method. I am using a currency manager for binding controls with a datatable....
1
by: Manuel Canas | last post by:
I'm stuck here guys, need some help. I have a form with a couple fo tabs on it. I load a table in each for each tab. I populate a listbox with a list of names. Then I use currency manager to...
0
by: Dennis | last post by:
I seem to be able to instantiate a currency manager from a bindingcontext using an arraylist but changes I make to the arraylist don't seem to trigger any of the Currency manager's events. ...
1
by: Doug Bell | last post by:
Hi, Hi had a DataGrid on a form and was using the CurrentCellChanged Event to determine the selected row: Private Sub grdSelOrd_CurrentCellChanged(ByVal sender As System.Object, _ ByVal e As...
6
by: Marina | last post by:
Hi, Let's say I have one datatable, that I want to use as the datasource for 2 dropdowns. So both are bound to the same one. But now, when I select a row in dropdown A, the selected row in...
5
by: Theodore | last post by:
Hi, i have a class "MyClass" with a public property of datatable type. I also have a form with a public property of type "MyClass". The form has a datagrid which binds to MyClass.Table datatable....
9
by: Trapulo | last post by:
Hello, with ASP.NET 2.0 Ajax every unexpected error is managed client-side with a popup that reports the error to the user. In ASP.NET 3.5 this behavor has been changed: how can I have a similar...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.