Windows Form Grand Child

Windows Form Grand Child

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


fredg posted on Wednesday, February 08, 2012

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();

 

JonnyBee replied on Thursday, February 09, 2012

Hi,

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

If so then you should have:

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.

Cymro replied on Thursday, February 23, 2012

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.

 

fredg replied on Thursday, February 09, 2012

"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?

JonnyBee replied on Thursday, February 09, 2012

Hi,

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

 

Copyright (c) Marimer LLC