3.0 Newbie, Winforms binding is killing me.

3.0 Newbie, Winforms binding is killing me.

Old forum URL: forums.lhotka.net/forums/t/3904.aspx


mtagliaf posted on Friday, November 16, 2007

Ok, I got 75% of the way through my first CSLA 3.0 project, using the BindingSources and such for binding, but I've run into my first problem with EditLevels and such.

After starting some digging into this forum and looking at the 3.0 ProjectTracker, it almost looks like the BindingSource is more trouble than it's worth.  All these workarounds with unbinding and such.

My current issue is a simple child object in a collection. I set it up as the Datasource of a Bindingsource, but when I call CancelEdit on the child object, the editlevel doesn't change.  I have tried some of the ProjectTracker "UnbindBindingSource" stuff, but I get an exception when that codes tries to set BindingSource.Datasource to nothing.

It looks like there are some very recent posts discussing this, but I feel like I'm way behind and need to see a decent example or a step by step recipe for using binding in 3.0 (the projecttracker code isn't porting for me at the moment)

Does this exist anywhere?


ajj3085 replied on Friday, November 16, 2007

The issue isn't with the bindingsource, its with how databinding works in general. 

Also, NEVER call CancelEdit on the objects directly once you bind the object to the bindingsource; you must call CancelEdit on the BindingSource. 

rsbaker0 replied on Friday, November 16, 2007

My interpretation of the CSLA binding mechanism is that you can't (or shouldn't) do any direct binding calls (BeginEdit/ApplyEdit/CancelEdit) on child objects, but instead should only do this on the parent. I'm a newbie though so I really don't know if this is right. Please feel free to correct me if I am wrong on this point.

We have had fairly good success at starting with an EditableRootlListBase, binding it to a grid control that supports binding (e.g. DevExpress XtraGrid), and then letting the ERLB object manage all the editing.

I've also taken an entire BusinessListBase object and bound it to a form, calling the edit functions only on the list itself rather than the child objects in the list and that has also worked.

Jurjen replied on Wednesday, September 10, 2008

Hello,


I'm using DevExpress XtraGrid (8.2.1) in my windows-application and am having some problems with child-collections. Editing is working just fine, but when adding a new child to the childcollection, strange things happen, the first keystroke (or selected date in dateedit) is discarded, while adding items in a similar fashion to a EditableRootCollection works just fine.

I was just wondering if anyone here had maybe solved this problem already, so I won't have to. Big Smile [:D]


TIA,
Jurjen.

Copyright (c) Marimer LLC