Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / September 2006

Tip: Looking for answers? Try searching our database.

Databindings - label doesn't update automatically when datasource changes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moongirl - 19 Sep 2006 09:35 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.