>> It's probably that the control is not aware that the boolean has
>> changed. Where is the boolean: in a DataSet, a BindingList<> or a
[quoted text clipped - 12 lines]
>Thanks,
>--Jeremy
I think my initial suspicion was correct, though it's difficult to be
absolutely sure without seeing your app. Basically, at the moment the
bound control is ignorant of any change in the object. To make it
aware you need to tell it something has changed, which you do by
implementing the INotifyPropertyChanged interface on your object. From
the Visual Studio help:
<quote>
"The INotifyPropertyChanged interface is used to notify clients,
typically binding clients, that a property value has changed.
For example, consider a Person object with a property called
FirstName. To provide generic property-change notification, the Person
type implements the INotifyPropertyChanged interface and raises a
PropertyChanged event when FirstName is changed. If your data source
implements the INotifyPropertyChanged and you are performing
asynchronous operations you should not make changes to the data source
on a background thread. Instead, you should read the data on a
background thread and merge the data into a list on the UI thread.
For change notification to occur in a binding between a bound client
and a data source, your bound type should either:
Implement the INotifyPropertyChanged interface (preferred).
Provide a change event for each property of the bound type.
Do not do both."
</quote>
There is example code too.
To be honest, I have never bothered with implementing this interface
because my objects always need to live within some sort of collection.
If you make this a specialization of the BindingList generic type:
public class ListOfMyBools : BindingList<MyBool> { }
Then you can get all the 2 way binding "for free" on any type of
object. BindingList broadcasts changes at item level rather than
item.property level (see page 650 of "Windows Forms 2.0 Programming"
by Chris Sells and Michael Weinhardt).
If you really want to understand data binding then I recommend the
book "Data Binding With Windows Forms 2.0" by Brian Moyes, published
by Addison Wesley.
--
Philip Daniels
Jeremy Chaney - 31 Jan 2007 01:14 GMT
>>> It's probably that the control is not aware that the boolean has
>>> changed. Where is the boolean: in a DataSet, a BindingList<> or a
[quoted text clipped - 61 lines]
> --
> Philip Daniels
This is great info. I'll give it a try, and I'll check out the book you
recommend. Thank you.
--Jeremy