Change zedgraph pane background color
Asked Answered
E

3

7

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.

Endoenzyme answered 9/8, 2011 at 14:22 Comment(0)
A
5

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 :)

Anticline answered 6/12, 2016 at 16:39 Comment(1)
I'll accept your answer because you are right, it will be more helpful for people having the same issue.Endoenzyme
J
6
myChart.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black;
Jere answered 9/8, 2011 at 14:31 Comment(2)
Not exactly what I'm looking for. I would like to change the color of the GraphPane, not only the Chart. In your case, the background color around the chart (axies, legends) is still white.Endoenzyme
Found what was missing: I have also to set: myChart.GraphPane.Fill.Color = System.Drawing.Color.Black; Noted as accepted even if it provides only the half of the answer ;) ThxEndoenzyme
O
5

myChart.GraphPane.Fill.Color = System.Drawing.Color.Black; will create a gradient fill started with black color. If you don't want to use gradient you should use -

myChart.GraphPane.Chart.Fill.Brush = new System.Drawing.SolidBrush(Color.Black);

Hope this will solve your problem.

Opiumism answered 5/10, 2012 at 9:6 Comment(0)
A
5

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 :)

Anticline answered 6/12, 2016 at 16:39 Comment(1)
I'll accept your answer because you are right, it will be more helpful for people having the same issue.Endoenzyme

© 2022 - 2024 — McMap. All rights reserved.