Trouble adding a DataPoint to a DataPointCollection

RyanS

New member
Joined
Nov 2, 2013
Messages
3
Programming Experience
1-3
Dim mydatapoint As DataPoint = New DataPoint(1, 1)
Dim mydatapointcollection As DataPointCollection = New DataPointCollection(mydatapoint)
mydatapointcollection.Add(mydatapoint)

Tried this but doesn't work
Trying to simply add a DataPoint to a DataPointCollection
 
Hi and Welcome to the Forum,

When posting to the Forum you should make sure that you post any errors that you currently receive so that we can help you in a more expedient manner. Having said that, have you taken the time to read and understand the error that you should be getting with these declarations:-

Dim mydatapoint As DataPoint = New DataPoint(1, 1)
Dim mydatapointcollection As DataPointCollection = New DataPointCollection(mydatapoint)

This error should be telling you that the DataPointCollection Class has been created as Friend. So, what does that mean? Have a read here to get an understanding of this:-

Friend (Visual Basic)

If you want a collection of DataPoints then just use a List(Of DataPoints). Have a look here:-

List(T) Class (System.Collections.Generic)


Hope that helps.

Cheers,

Ian
 
Thanks, just one more thing though
How would I use this List(of DataPoints) to add Points to a Series in a Chart?
Thanks again
 
Hi,

If you already have a collection of DataPoints then you can use a For loop to iterate through that collection and then add those DataPoints to a Chart Series using the AddXY Medhod of the Points collection. i.e:-

Chart1.Series("YourSeries").Points.AddXY(XValue, YValue)


In addition to this, and if you look closely enough, you will notice something here that relates to your initial post. Can you see what it is?

Hope that helps.

Cheers,

Ian
 
Back
Top