Getting the Input
We invite the user to enter the four elements of data - Name, Amount, Color and Pattern - for any single slice of the pie. If they don't enter a choice, a default value is used.
When the user is happy with the "current set" of data (that is, what will become one segment of the pie) a click on the Confirm button will fire the following code. This takes those four pieces of data and stores them in the arraylist as one composite GraphData element.
Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click
' Add latest item of data to the arraylist
If txtName.Text = "" Then txtName.Text = "No Name"
Dim gd As New GraphData
gd.Name = txtName.Text
gd.Amount = nudValue.Value
gd.Clr = clrPicked
gd.Pattern = hatchPicked
I'm sure you will have spotted the inclusion of the line which checks that the user has actually entered a Name and, if not, assigns some text for display.