locked
Error about creating a vertical line annotation RRS feed

  • Question

  • I want to add a vertical line to chart. These is the code of I wrote shown as below.

    VerticalLineAnnotation vl = new VerticalLineAnnotation();
    vl.Height = 20.7;
    vl.Name = "VerticalLineAnnotation";
    vl.AxisX = new Axis(m_Chart.ChartAreas[0], AxisName.X);  <====I got error(system.NULLReference.Exception) on this line.
    vl.Y = 54;
    vl.LineColor = Color.Black;
    What could cause this error on creating a vertical line annotation ?? Thanks

    Tzeng 
    Tuesday, March 16, 2010 12:36 PM

Answers

  • You should assign an existing axis to the AxisX-property, not create a new one.

    vl.AxisX = m_Chart.ChartAreas[0].AxisX;
    Tuesday, March 16, 2010 1:13 PM
    Moderator

All replies

  • You should assign an existing axis to the AxisX-property, not create a new one.

    vl.AxisX = m_Chart.ChartAreas[0].AxisX;
    Tuesday, March 16, 2010 1:13 PM
    Moderator
  • Thank you very much. Now, it works very well. 

    Best Regards

    Tzeng
    Tuesday, March 16, 2010 2:51 PM
  • When someone answers your question, please mark it as the answer.

    Thanks!


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Saturday, January 21, 2012 3:13 AM