title: How to create a new curveitem for a rolling graph?
body: <p>I am trying to create a rolling graph using zedgraph. I used the code  given in the website 
  <a href="http://zedgraph.dariowiz.com/index3061.html" rel="nofollow">http://zedgraph.dariowiz.com/index3061.html</a> . It is working properly. The graph in the sample has been implemented using curveitem as follows:</p>
  
  <pre><code>if ( zedGraphControl2-&gt;GraphPane-&gt;CurveList-&gt;Count &lt;= 0 )
      return;
  
  // Get the first CurveItem in the graph
  LineItem ^curve = dynamic_cast&lt;LineItem ^&gt;(zedGraphControl2-&gt;GraphPane-&gt;CurveList[0]);
  
  if(curve == nullptr)
      return;
  
  
  // Get the PointPairList
  IPointListEdit ^list = dynamic_cast &lt;IPointListEdit^&gt;(curve-&gt;Points);
  
  // If this is null, it means the reference at curve.Points does not
  // support IPointListEdit, so we won't be able to modify it
  if ( list == nullptr)
     return;
  
  // Time is measured in seconds
  double time = (Environment::TickCount - tickStart);
  
  Output_data = CreateVariable(0);// User defined function
  
  
  list-&gt;Add(time, Output_data);  
  </code></pre>
  
  <h2>I tried to create second curve by appending the following code:</h2>
  
  <pre><code>LineItem ^curve1 = dynamic_cast&lt;LineItem ^&gt;(zedGraphControl2-&gt;GraphPane-&gt;CurveList[1]);
  
  if(curve1 == nullptr)
      return;
  
  // Get the PointPairList
  IPointListEdit ^list1 = dynamic_cast &lt;IPointListEdit^&gt;(curve1-&gt;Points);
  
  // If this is null, it means the reference at curve.Points does not
  // support IPointListEdit, so we won't be able to modify it
  if ( list1 == nullptr)
      return;
  
  // Time is measured in seconds
  double time = (Environment::TickCount - tickStart);
  
  Output_data = CreateVariable(0);// User defined function    
  
  list1-&gt;Add(time, Output_data); }
  </code></pre>
  
  <p>Now the question is how to create a second LineItem?</p>
  
  <p>If I type:
  LineItem ^curve1 = dynamic_cast(zedGraphControl2->GraphPane->CurveList[1]);
  it shows an error during debug, saying CurveList[1] does not exist. </p>