0

I am generating the graph at runtime using zedgraph control. The graph is generated but the line color of zedgraph control changes as the background color. I want to set the same color that was set at design time. How to set fix color to line? I am using the code to give color as :

refLine = gp.AddCurve("", null, null, Color.Green , SymbolType.None);

at the load event of form. But it gets changed automatically.

bretddog
  • 5,411
  • 11
  • 63
  • 111
  • 1
    Please provide what you've tried in an [edit]. – LW001 Oct 18 '17 at 07:48
  • Welcome to Stack Overflow! Pure code-writing requests are off-topic on Stack Overflow -- we expect questions here to relate to specific programming problems -- but we will happily help you write it yourself! Tell us [what you've tried](https://stackoverflow.com/help/how-to-ask), and where you are stuck. This will also help us answer your question better. – WhatsThePoint Oct 18 '17 at 07:52

1 Answers1

0

You have:

refLine = gp.AddCurve("", null, null, Color.Green , SymbolType.None);

Which returns a LineItem. There are at least two different color properties. Above you set the LineItem.Color property. Try after to set this :

refLine.Line.Fill.Color = Color.Green;
zgc.Refresh();  //not sure if needed

Can't remember what the LineItem.Color property is, but it may be a fill color for other views than line chart, for example bar or candlestick charts.

Also, due to the complexity of Zedgraph, be sure to use good documentation.

bretddog
  • 5,411
  • 11
  • 63
  • 111