Hi,
I've got WinGrid bound to some custom business logic which inherits from System.ComponentModel.BindingList.
When I dynamically set the AllowEdit property of the datasource, WinGrid correctly prevents or allows the edit of cells.
I want to also display the new "template" row on the bottom of the grid - but only when the AllowNew of the datasource is True. To do so, I need to detect when the AllowNew property of the datasource changes and set the Layout.Override.AllowAddNew appropriately. I also want to do something similar when the AllowRemove property of the datasource changes.
I've had a look at documentation on WinGrid's events and can't see anything which I could hook into.
For reasons I won't go into here I can't use the PropertyChanged event of the BindingList (I tried, but found issues with typecasting).
Thanks,
Mike
Hello Mike, Is far I understand your scenario correctly you need to handle when “AllowNew” of the datasource is changed. But this is related to your implementation of DataSource, is not related to WinGrid. As you mention you need to handle that change and set the Layout.Override.AllowAddNew appropriately. The event PropertyChanged is related when some property of your business object is changed and his purpose is to notify when the content of your business object is changes. So my idea is to go to implementation of your DataSource that implement IBindingList and add your custom event to fire when the AllowNew is changed. In the grid functionality you can handle that event and do the appropriate action in order to the Layout.Override.AllowAddNew. Also you can try to use OnListChanged when the collection is changed, in order to handle when the collection is changes.I hope this information was helpful enough.DimiDeveloper Support Engineer
In the event that no such event exists, I'm looking at an alternative technique to achieve the same result.
I have found that in the InitializeRow event I can examine the datasource.AllowNew, AllowRemove properties and set the Layout.Override.AllowAddNew property appropriately.
However, the one drawback I have with this is InitializeRow is not called when the datasource has had it's list cleared using the ClearList() method (remember it's a system.componentmode.bindinglist). I've tried the AfterRowsDeleted and InitializeRowsCollection but these are not invoked either.
What event could I use to detect when the grid has it's rows emptied because the datasource it is bound to has been cleared using ClearList() ?