Hi,
I'm fairly new to databindings and trying to get my head round how it
works. We are developing a windows application which references a dll
which is a custom object, Meeting, and the Meeting object contains a
list of 'Races', i.e. List<Race>. The Meeting object is defined as a
datasource (meetingBindingSource) and the List<Race> is defined as a
datasource(racesBindingSource).I have a datagridview which is databound
to racesBindingSource and a binding navigator which enables me to step
through each race. I have a panel which contains a set of labels which
I use to show some information about the currently selected race. Each
of these labels is databound to a property of the Race object in
racesBindingSource as follows:
this.lbRaceStatus.DataBindings.Add(new
System.Windows.Forms.Binding("Text", this.racesBindingSource,
"RaceState", true));
When new data arrives, the Meeting object, and Races are updated and
the datagridview updates automatically, but the label does not. If I
select a different race and then return to the previous one the correct
data is showing so I know the object is updated, but why won't the
label update automatically?
I have tried changing the DataSourceUpdateMode for the label and have
tried all 3 settings, OnPropertyChanged, OnValidation and Never and
none of them seem to get the label to update automatically.
Can anyone point me in the right direction on this??? I'm stumped!
Bart Mermuys - 19 Sep 2006 13:57 GMT
Hi,
> Hi,
> I'm fairly new to databindings and trying to get my head round how it
[quoted text clipped - 19 lines]
> data is showing so I know the object is updated, but why won't the
> label update automatically?
You should put the Race objects in a BindingList<Race> and Race should
properly implement INotifyPropertyChanged to support all notifications. Not
sure why your DGV is already updating though... it's not clear how you're
updating the races with new data either.
HTH,
Greetings
> I have tried changing the DataSourceUpdateMode for the label and have
> tried all 3 settings, OnPropertyChanged, OnValidation and Never and
> none of them seem to get the label to update automatically.
>
> Can anyone point me in the right direction on this??? I'm stumped!