07-27-2009 04:05 PM
It seems to be simple (sur it will be), but i spent 2 hour trying to add an annotation to a scattergraph.
It's working perfectly in design mode, but i want to do it by code, something like this:
Dim ann As New XYAnnotationCollection
ScatterGraph1.Annotations.Add(ann)
But this is not working, ann is a XYAnnotationCollection not a XYAnnotation. And when i declare it as XYAnnotation, it wont work too, (mustinherit class)!!!
Using VB 2005
Thank's in advance.
Solved! Go to Solution.
07-28-2009 09:44 AM
A quick tip is you can always see the code that is made during Design mode in your code by just unhiding the "Required by the Windows Form Designer" code at the beginning of your program. Here if we make an annotation we can see how VS codes it and copy their syntax.
Me.XyPointAnnotation1 = New NationalInstruments.UI.XYPointAnnotation
Me.ScatterGraph1.Annotations.AddRange(New NationalInstruments.UI.XYAnnotation() {Me.XyPointAnnotation1})
Me.XyPointAnnotation1.Caption = "XyPointAnnotation1"
Me.XyPointAnnotation1.CaptionAlignment = New NationalInstruments.UI.AnnotationCaptionAlignment(NationalInstruments.UI.BoundsAlignment.None, 0.0!, 25.0!)
Me.XyPointAnnotation1.XAxis = Me.XAxis1
Me.XyPointAnnotation1.XPosition = 1
Me.XyPointAnnotation1.YAxis = Me.YAxis1
Me.XyPointAnnotation1.YPosition = 9
It sounds like you may not be initalizing thethe annotation correctly.
Regards,
Steven Zittrower
Applications Engineer
National Instruments
07-29-2009 03:16 PM
Thanks For The Tip. Really helpfull.
If it can help someone else, I got it work by using a clone of the first annotation -wich was made by design and invisible-
Dim ann As XYPointAnnotation For i = 0 To Nmax
ann = frmsuivi_tendance.XyPointAnnotation1.Clone()
ann.Visible = True
next i