StrataFrame Forum

Synching DataGridView with businessBindingSource BO

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

By Mark Dowlearn - 1/17/2007

Hello -

I know I'm missing something simple here, but I'm new to working with both Strataframe and DataGridView objects.

I'm setting up a maintenance form for a table.  BO created, businessBindingSource mapped to the BO, DataGridView dataSource set to the businessBindingSource.

DataGridView is filled in ParentFormLoading () of the BO; data is displaying successfully. 

I'm able to sync the display of the BO to the DataGridView using the Navigate() method in the DataGridView's cellClick method().

What I'm not able to do is have the grid update to reflect the navigation that takes place when using the MaintenanceFormToolStrip on the maintenance form.  I know that the current record in the BO is available through the NavigatedEventArgs on the BO, but I'm unable to find the correct property to set or the correct method to call to set the DataGridView's pointer to the current index and then refresh the display.

I'm sure I'm missing something simple, but I'm stumped.  Any suggestions?

Mark

By StrataFrame Team - 1/17/2007

Most grids have a property such as SyncToCurrencyManager or something like that that tells the grid to stay in sync with the ICurrencyManager.Position, which is set by the navigate methods.  There was a problem with the grid matching the position of the business object when the business object was navigated, but it was fixed some time ago, so I don't think that's your issue. 
By Mark Dowlearn - 1/17/2007

Ben -

This is just a plain vanilla Microsoft DataGridView -- I don't see any property listed as SyncToCurrencyManager or something similar.  Any other suggestions?

Yours,

m

By Mark Dowlearn - 1/17/2007

OK -- I believe I've got it going after doing further research on CurrencyManager and BindingContext.  Thanks for the hint in this direction.

For the benefit of anyone else who might need to do this, In order to sync the grid with the BO (and other controls bound to the BO), I set the CurrencyManager.Position property to the CurrentRowIndex of the NavigatedEventArgs object in response to the Navigated() event:

CurrencyManager currencyManager = (CurrencyManager)this.dataGridView1.BindingContext[businessBindingSource1];

if (currencyManager != null)

{

currencyManager.Position = e.CurrentRowIndex;

}

By StrataFrame Team - 1/18/2007

It's weird that it wouldn't be working for you automatically... because that's exactly what the BBS does internally...

Private Sub BusinessObject_Navigated(ByVal e As NavigatedEventArgs)

'-- Make sure we're not changing the position

If Not Me._ChangingPosition Then

Me._ChangingPosition = True

'-- Change the currencymanager's position

If Me.ICurrencyManagerProvider_CurrencyManager IsNot Nothing Then

Me.ICurrencyManagerProvider_CurrencyManager.Position = e.CurrentRowIndex

End If

Me._ChangingPosition = False

End If

End Sub