Multiple bindingcontext on winform


G

Guest

Hi All,

Does anyone know of a reference for adding panels with there own binding
contexts and keeping them synchronized with the form's bindingcontext?

Thanks,
Carl
 
Ad

Advertisements

J

Jeppe Jespersen

Does anyone know of a reference for adding panels with there own binding
contexts and keeping them synchronized with the form's bindingcontext?
Could you elaborate on why you want to do this?

Jeppe Jespersen
Denmark
 
G

Guest

Hi Jeppe,

Thanks for your interest in my problem. This is probably more detail than
you were looking for :) but here it goes:

Data Model: a 4-level relationship consisting of:
1. Order - Customer ID, order date, etc.
2. Order Detail - type of item, lens prescription, etc.
3. Order Detail Component - type of component such as frame or lenses
4. Order Detail Component Specification - specification for component such
as frame size or lens tint

On the WinForm I want to show the orders for a customer and, for each order,
show the order detail(s) associated with the order while allowing the user to
navigate through the orders and details. The standard form-based
BindingContext and CurrencyManager will handle this.

I also want to show the Order Detail Components and their specifications.
Each Order Detail typically consists of 2 components - a frame and lenses.
Since these are at the same "level" the single form-based BindingContext and
CurrencyManager will only allow the form to position to one of the Components
at a time.

To get around this I've created two panels each with their own
BindingContext and CurrencyManager that can act independently. However, to
do this each panel needs its own independent CurrencyManager (aka
BindingMangerBase) for the Order and Order Detail datasets. So now I have
three independent hierarchies: Form based, Frame Panel based, and Lens Panel
based.

The challenge comes with keeping them synchronized at the order and order
detail level. This appears to be deeper and more complex than simply setting
the currency manager positions. The particular problem I'm dealing with now
is that adding a new order corrupts a previously entered and saved order by
overwriting its value with the new record values.

I've started working with MS Tech Support on this and it seems to be related
to position setting but I haven't figured out the real reason for the
problems and may only be dealing the symptoms instead of the route cause.

So...I'm looking for information on this. While "best practices" would be
nice "any practices" would be helpful. The only reference I've found so far
is the very simple example in the help topic for the Binding Manager
constructor.

Thanks again,
Carl
 
C

ClayB [Syncfusion]

Do not know whther this will affect the problem you are seeing or not. But
you might try calling Refresh on your CurrencyManagers before you try to
sync up their positions. This has cleaned up some problems for me when
trying to work with adding new items to empty related childtables.

==================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
Ad

Advertisements

G

Guest

Hi Clay,

Thanks for your thoughts. I had tried calling refresh but it didn't seem to
make a difference.

At this point it's looking like it has something to with how my key values
are cascading after calling the data adapter update method when I have
multiple rows being inserted. While previously I was only seeing symptoms
after the rows were written to the database, I'm now seeing FK constraint
exceptions on my third-level table when I try to do the initial insert. The
data row looks fine but the Insert Command FK Parameter has the temp key
value instead of the updated key value.

The work around I've put in is to set the FK parameter's value explicitly in
the Updating event. This seems to fix this most recent symptom but I haven't
tested with the forth-level yet.

Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top