When I have a listview with like 46 items, where each item has 4 subitems, the values of the subitems are changing with time, I use the values of subitems to draw a pie chart when an item in the list view is selected using this code:
Chart1.Series("Series1").ChartType = SeriesChartType.Pie
Chart1.Series("Series1").Points.Clear()
If ListView3.FocusedItem.SubItems(1).Text > 0 Then
Chart1.Series("Series1").Points.AddY(ListView3.FocusedItem.SubItems(1).Text)
End If
If ListView3.FocusedItem.SubItems(2).Text > 0 Then
Chart1.Series("Series1").Points.AddY(ListView3.FocusedItem.SubItems(2).Text)
End If
If ListView3.FocusedItem.SubItems(3).Text > 0 Then
Chart1.Series("Series1").Points.AddY(ListView3.FocusedItem.SubItems(3).Text)
End If
If ListView3.FocusedItem.SubItems(4).Text > 0 Then
Chart1.Series("Series1").Points.AddY(ListView3.FocusedItem.SubItems(4).Text)
End If
Is there a way to detect a change of a subitem’s value? Like onchange event in textbox, but for items or subitems, because I want the pie chart to update when a subitem value changes.
this code changes the sub items
For xx As Integer = 0 To ListView3.Items.Count - 1
If ListView3.Items(xx).SubItems(0).Text = googleXMLdocument...<s:name>(j).Value Then
If j + 1 = 1 Then
ListView3.Items(xx).SubItems(1).Text += 1
End If
If j + 1 = 2 Then
ListView3.Items(xx).SubItems(2).Text += 1
End If
If j + 1 = 3 Then
ListView3.Items(xx).SubItems(3).Text += 1
End If
If j + 1 > 4 Then
ListView3.Items(xx).SubItems(4).Text += 1
End If
End If
Next
Try this code. This way the chart will automatically get updated if there is any change in the subitems. You will not require a timer.
Put the below code after the above code in a loop. You can also do away with the
FocusedItem