Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Detecting when WinGrid's datasource AllowNew and AllowRemove changes
posted

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

Parents
No Data
Reply
  • 12773
    posted

    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.

    Dimi
    Developer Support Engineer

Children
No Data