StrataFrame Forum

BBS issue

http://forum.strataframe.net/Topic32220.aspx

By Keith Chisarik - 9/26/2013

Scenario:

DataGridView with BBS as its datasource, BBS BO set to a BO on my form. All works fine when DataGridView is on the form. If I move the datagridview into a container (ThemedContainer) and it no longer syncs.

Why and how to fix please?
By StrataFrame Team - 9/27/2013

Ok, Keith, I finally got this one figured out.  Something, I have no idea what, is accessing the BindingContext of the ThemedContainer in the setup and loading of the form before the form's BindingContext is created, so the ThemedContainer just creates its own BindingContext.  Any other control on the form that doesn't have its own BindingContext uses its parent's, which cascades up to the form's BindingContext.  The BindingContext is the object that creates the CurrencyManager, which controls the currently selected item.  So, by having the DataGridView in a ThemedContainer, it is using a different CurrencyManager because it has a different BindingContext.

Luckily for us, BindingContext is not read-only Smile

So, adding the following line of code right after the InitializeComponent() call in the constructor fixes it.

public Form1()
{
   InitializeComponent();
   this.themedContainer1.BindingContext = this.BindingContext; //<-- This line sets the BindingContext of the ThemedContainer back to the BindingContext of the form
}

That should get you fixed.
By Keith Chisarik - 9/27/2013

That worked, thanks.