Having a bunch of issues with InitializeRow not be fired at appropriate times that have been logged with the dev team already. But this one is so basic I need some quick guidance:
I bind my UltraGrid to a BindingSource which in turn is bound to a datasource of type BindingList<T> (of objects that implement INotifyPropertyChanged).
When I raise a PropertyChanged(null / empty) from the objects I expect to get a ListChangedType.Reset event raised in the BindingSource. And I do. What I do not get is any InitializeRow events called in the grid - I expected that I would. I used to in older versions (using .net2 with v7.3).Any pointers? Like, why does the grid not fire initializerows so when it gets a reset event from the list?
Thanks,John
John,
There really isn't any generic reason why InitializeRow wouldn't fire. As you have stated that you have submitted your issues with the development team, the cause will have to be determined by the sample project assigned to the bug. I do know that there are sometimes issues with a BindingSource because the grid doesn't create the BindingManager/CurrencyManager for recursive bands, for performance reasons, so if you're not using the BindingSource to work around the CurrencyManager issue introduced with CLR2.0, you could try not using the BindingSource for now.
-Matt
Thanks for the reply Matt. On you folks recommendation I am using the BindingSource these days to avoid CurrencyManager funkiness. The item i have submitted to support is a little different than this one - ItemChanged not causing InitializeRow in a deep hierarchy but this one is just the simplest case. Not even talking hierarchy. The bindingsource is getting a ListChangedType.Reset but the grid, although it has the data, doesn't fire any event.
Anybody else experiencing this?
....just some more info on this: when the PropertyChanged event is raised the BindingSource gets the Reset event then the Grid gets the following - none of which cause an InitializeRow to be called:
UltraGridBase.BindingListChanged...case ListChangedType.Reset: // SSP 9/4/03 UWG2629 // If the grid's binding manager is the same as the band's binding manager, // then let the band handle the Reset. // //this.Set_ListManager( this.DataSource, this.DataMember ); if ( null == this.layout || this.layout.Bands.Count <= 0 || this.BindingManager != this.layout.Bands[0].BindingManager ) { this.Set_ListManager( this.DataSource, this.DataMember ); } break;
RowsCollection.OnListChanged... case ListChangedType.Reset: { // On a list reset, init the rows. // // SSP 2/19/04 // //this.InitRows( ); this.DirtyRows( );
break; }
UltraGridBand.OnListChanged...no handling of ListChangedType.Reset:
Hi Krzysztof,
What is m_list in your example? What type is it?
My first reaction is that the InitializeRow event should fire for every row in the grid when the grid gets a reset notification. But since I don't know what kind of data source you are using, I cannot test it to see why it's not working.
If you could post a small sample project demonstrating the issue, that would be a big help in tracking it down.
If you want to just work around the issue, it's very easy. After you call ResetBindings, call grid.Rows.Refresh(FireInitializeRow).
Hi Mike
It is BindingList of course. I attached an example.
I use your suggestion for now, but just wondering if this shouldn't be something gird always does, without an extra implementation.
In the example
Update button updates first row (index - 0)
Krzysztof
Hi Mike,
I am also using BindingList and on ResetBindings expecting InitlalizeRow to be called for all the rows. This isn't happening.
Bhavesh
Hello Bhavesh and Krzysztof,
I will be happy to assist you with this issue.
This issue appears to be a bug. I have created a case for you to better assist you with this issue going forward. To access the case, simply log into your IG account and click on My Support Activity.
Please let me know if you have further questions in this matter utilizing the case created.
I have updated your cases. Please view the case to find full details about the solution.
When you know you want InitializeRow to re-fire, your best option is to use grid.Rows.Refresh(FireInitializeRow).
Please let me know if you have further quetions in this matter.