all groups > dotnet windows forms databinding > september 2006 >
You're in the

dotnet windows forms databinding

group:

Databindings - label doesn't update automatically when datasource changes


Databindings - label doesn't update automatically when datasource changes moongirl
9/19/2006 1:35:11 AM
dotnet windows forms databinding:
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!
Re: Databindings - label doesn't update automatically when datasource changes Bart Mermuys
9/19/2006 12:57:51 PM
Hi,

[quoted text, click to view]

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

[quoted text, click to view]

AddThis Social Bookmark Button