CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Windows Form Grand Child

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 2 Followers

Top 150 Contributor
56 Posts
fredg posted on Wed, Feb 8 2012 7:23 PM

Hi,

  I'm working on a windows form (implementing a Winpart). This control contains a DataGridView bound to a Grand Child Collection.

    1. Do we need to bind from the root object, then child object, then grandChild ? Or just bind from child object?

    2.  In  RebindUI(), when saving, is it enough to just save the root object:

              root = root.Save();

 

All Replies

Top 10 Contributor
1,770 Posts

Hi,

1. Are you creating a UserControl that contains a DatagridView?

If so then you should have:

  • UserControl only knows about the objects it needs to know (items for list)
  • Provide methods for Bind / Unbind to datasource(s)

It should be the outside forms responsibility to set up databinding properly.

2. You can never call Save on an object that has active databinding - so your form must always make sure to unhook databinding before calling save.

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
56 Posts
fredg replied on Thu, Feb 9 2012 9:25 AM

"Are you creating a UserControl that contains a DatagridView?"

  No.

---------

Is there any sample code which demonstrates how to deal with grand child object for windows form?

Top 10 Contributor
1,770 Posts

Hi,

The only sample I can remember is Samples\Net\cs\RootChildGrandchildWinFormTest in the Samples download.

 

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
5 Posts
Cymro replied on Thu, Feb 23 2012 8:32 AM

Hi Jonny,

I have a similar scenario , I have a Form hosting several UserControls.  The Root object has several Child Lists, maintained by each of the UserControls and all using data binding.

My complication is that a couple of these Child Objects have Grand Children and these are maintained on a Modal Form created from the responsible UserControl.  

My problem is how to handle the Accept / Cancel buttons on the Modal Form.  I know need to be able to initiate a new edit level on entering the form with a BeginEdit and either ApplyEdit or CancelEdit depending on the DialogResult and that I need to Unbind before doing so.  What I am unsure about is whether I need to Unbind everything (i.e. the whole object graph from the main Form) and call the BeginEdit on the Root object or whether I can just Unbind just the Child List I am working with and start an BeginEdit on the Child List.

Your advice would be greatly appreciated.

 

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems