Search code examples
c#objectzedgraph

How to Remove specific graph objects in Zedgraph


I'm trying to remove a specific graph object from the zedgraph, is it possible....?

I have a zedgraph, which has multiple curves and multiple graph objects...

GraphPane pane = zedGraphControl1.GraphPane;

// Create two Line Onjects
LineObj BlueLine = new LineObj(Color.Blue, 10, 10, 10, 100);
LineObj RedLine = new LineObj(Color.Red, 90, 10, 90, 100);

// Add the line objects
pane.GraphObjList.Add(BlueLine);
pane.GraphObjList.Add(RedLine);

I know that with the help of

pane.GraphObjList.Clear();

I can clear all the objects but I want to remove the Redline alone..?

Thanks for your time...:)


Solution

  • If you use LineItem instead of LineObj, you can use LineItem1.clear() to remove single curves.

    You can fill it with a PointPairList, and add it to your pane:

    LineItem1 = pane.AddCurve("CurveName", PointPairList1, Color.White, SymbolType.None)