I am trying to update a datagridview and a chart.
I have a class and in that class I have a function that returns a datatable from database.
I need the bindingSource because this is how I update chart (bar)
Unfortunately when the chart is Pie I need to use a datatable for updating
So when I load the form I have:
gbsGraph.DataSource = graphFunctions.prepareData() 'gbsGraph is a BindingSource
gdtGraphData = graphFunctions.prepareData() 'gdtGraphData isDataTable
gdv.DataSource = gbsGraph 'gdv is my datagridview
AddHandler gdtGraphData.RowChanged, AddressOf gdtGraphData_RowChanged 'add event for update piechart
fillChart()'code to fill the chart
When the user press the refresh button:
Private Sub tsmiRefresh_Click(sender As System.Object, e As System.EventArgs) Handles tsmiRefresh.Click
gbsGraph.DataSource = graphFunctions.prepareData()' this works and dgv and my bar charts are updated
gdtGraphData = graphFunctions.prepareData() 'this is should trigger the event gdtGraphData.RowChanged but it doesn't
End Sub
My custom event for DataRowChange:
Private Sub gdtGraphData_RowChanged(ByVal sender As Object, ByVal e As DataRowChangeEventArgs)
'Here is code to refill the Pie chart
'but the event isn't fired
End Sub
So my question is how I can update my datatable and fire the gdtGraphData_RowChanged event?
Thanks
T
The row changed event is raised when a value inside a row inside a datatable is changed, not when you put a new instance of a datatable into a variable …
An example:
You will have to put the code to refill the Pie chart inside the tsmiRefresh_Click …