I’m not so familiar with bindingsources. The short question is: How do you bind a chart to a datasource so that when the BindingNavigator is changed the chart display updates?
My long winded explanation is below:
I have a datasource I have imported into C# VS 2010 Express. It is a related dataset, in that there are 2 tables (Asset, Historical_prices), where each asset has a table of related historical prices.
I simply draged and droped my datasource into the form and was able to create the view I wanted, with the help of the BindingNavigator. I dragged a DataGrid view of the Historical_prices table into the form as well, and it updates when the BindingNavigator is clicked
I then created a chart in the form, which I selected the DataSource as the historical_pricesBindingSource. It loads
I want to be able to update the chart with different Historical_prices when the BindingBavigator is changed but it currently doesnt. Any ideas?
I tried adding chart1.Update(); in the BindingNavigatorSaveItem_Click event but no dice.
Thank you kindly
The Binding needs to actually be databound instead of just assigned. What you have done is essentially created a One-Time binding that occurs at Runtime during Initialization or Value Assignment.
This means that your Target (The Chart) Only Updates One-Time, when the Source (the DataSource) is Created by the view.
What you are looking for is a Two-Way binding. So that the Target is updated ANYTIME the Source is modified.
To Achieve this you would generally need to bind the DataSource to the TargetProperty using the Two-Way binding syntax.
Your Data Source will need to Implement the INotifyPropertyChanged Interface though in order to notify the UI that it needs to be updated.
The Code for Implementing INotifyPropertyChanged is:
For More info in INotifyPropertyChanged: http://msdn.microsoft.com/en-us/library/ms229614.aspx