Search code examples
c#zedgraph

Change zedgraph pane background color


Is it possible to change the background color (white by default) of a zedgraph pane?

I tried changing the background color of the zedgraph element, but it doesn't give any visible result, background is still white:

ZedGraphControl.BackColor = System.Drawing.Color.Black;

And there doesn't seem to exist a Color or BackColor property on ZedGraphControl.GraphPane.


Solution

  • You can use

    zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;
    

    to change the background [only] of the chart. If you want to change the background color the zedgraph except the chart, use

    zg.GraphPane.Fill.Color = SystemColors.ControlText;
    

    If you want to change the background color of everything in the zedgraph, use both:

    zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;
    zg.GraphPane.Fill.Color = SystemColors.ControlText;
    

    EDIT: I know that you already solved your problem but I made this so if someone searches it, he can solve his problem quickly :)