PropertyHasChanged and Bindingsource problem

PropertyHasChanged and Bindingsource problem

Old forum URL: forums.lhotka.net/forums/t/8986.aspx


KevinR posted on Tuesday, May 25, 2010

Winforms, Visual Studio 2008, CSLA 2.1.1.0

Hello, I have a problem with a DataGridView with a combobox.

The grid is bound to a BusinessListBase via a bindingsource and the comboboxes list comes from another bindingsource which is bound to a different business list base collection. The items in the combobox datasource are a property of the containing data grid view's datasource.

Now, on the current changed event of the combobox I set the apropriate property of the current row, in the setter for this property I call PropertyHasChanged. The issue is that calling PropertyHasChanged ultimately results in the OnListChanged event of the main collection being raised, which - via the magic of databinding - calls the CurrentChanged event again resulting in the selected value being replaced by a blank item.

If I remove the PropertyHasChanged call the property is set but obviously my IsDirty is not set and the Validation is not called.

Any ideas?

RockfordLhotka replied on Tuesday, May 25, 2010

You should at least upgrade to the latest 3.0.x version of CSLA. Many, many bugs, especially around Windows Forms data binding, were addressed in the 3.0 version of CSLA.

KevinR replied on Tuesday, May 25, 2010

Hi Rocky,

Unfortunately that is not under my control and, at the moment, not an option. I'm not sure it is a bug, it might be something I am doing wrong.

 

RockfordLhotka replied on Tuesday, May 25, 2010

I'm 95% sure that is a bug that was fixed. It sounds very familiar, and has to do with the PropertyChanged event from child objects messing with datagrid controls. It was one of the things fixed in 3.0.

KevinR replied on Tuesday, May 25, 2010

OK  thanks Rocky. I'll try that in isolation, but the project I'm working on is big so upgrading anything is difficult. I'll suggest it though.

In the meantime I've overridden the PropertyHasChanged event in my business object  so that it doesn't call the OnPropertyChanged method in the base class method  - this suits my specific requirements as it happens and now works just as I wanted.

Thanks for the info about version 3.

Copyright (c) Marimer LLC