The Oops! Option
We’re almost done. The user can enter as much data as they like and the chart can be refreshed each time to display the data and the pattern/color choices. But there may come a time when the user wants to start over again.
Rather than forcing them to close the application and fire it up again, let’s finish off by giving them a button to remove the data and clear the decks for another go.
This code in the Click event of the Restart button is all that is needed:
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
UserData.Clear()
pnlChart.Invalidate()
End Sub
Our new friend, the Invalidate method, once again does most of the work for us, once we have removed all data from the arraylist.