Question Chart refresh

bsutton

New member
Joined
Sep 22, 2011
Messages
3
Programming Experience
10+
Hi all, first post here.

I am using the chart control to graph, unit sales for an item, selected from a dropdown list. This works perfectly, for the first selected item, but fails on the second, at this line

Chart1.DataBindTable(myReader, "Period")

I know it is because I am trying to Bind again, but how do I unbind the first set of data. I have tried Chart1.dispose(), but am just guessing for the correct answer. Hoping someone can steer me in the right direction.

Thanks
 
Try this before DataBindTable call:
Chart1.Series.Dispose()
Chart1.Series.Clear()
 
I used these commands with the Chart1.dispose(), and that worked.
If removing the Chart control from the form to discard it then it's a good idea to dispose it, but then your original question makes no sense.
 
Your correct, the command I used was
Chart1.DataBindings.Clear()

Then

Chart1.Series.Dispose()
Chart1.Series.Clear()

then I rebound my Chart with the data from the next item selected

Chart1.DataBindTable(myReader, "Period")

Bill
 
DataBindTable doesn't configure any DataBindings, so that is not relevant. DataBindTable method just add Series and load the point data.
 
Back
Top