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.
myChart.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black;
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 :)
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.
Related
I am creating an application for a new RPG that I am creating. The application has a specific theme and I want to change the checkboxes and buttons to black and the cyan color I chose. On loading the form I use the following code to change the color of the boxes.
coloredCheckBoxes.Add(checkBox1);
coloredCheckBoxes.Add(checkBox2);
foreach (CheckBox checkBox in coloredCheckBoxes)
{
checkBox.FlatStyle = FlatStyle.Flat;
checkBox.FlatAppearance.BorderSize = 1;
checkBox.FlatAppearance.BorderColor = Color.FromArgb(0, 211, 211);
checkBox.FlatAppearance.CheckedBackColor = Color.Black;
checkBox.FlatAppearance.MouseOverBackColor = Color.Black;
checkBox.FlatAppearance.CheckedBackColor = Color.Black;
checkBox.BackColor = Color.Black;
}
No matter how many colors I change the back color of the check boxes still remain this weird grey color.
The check boxes also become lighter if I move my cursor over the boxes as if checkBox.FlatAppearance.MouseOverBackColor = Color.Black; was not used. Is there a way to fix this issue hopefuly without creating a custom checkbox class?
I understand what you need finally.(I remove any old answer)
Try this,
- MetroFramework UI - Original by Peter.
- MetroFramework UI - Forked, dennismagno(Recommand).
- MetroFramework UI - Forked, thielj.
Also provided source code, so you can modify it.
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.
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.
I've tried to change the background of a ComboBox using:
comboBox.BackColor = Color.Crimson;
And I get white borders like this:
You can set additionally to the BackColor the FlatStyle to flat:
this.comboBox1.BackColor = Color.Red;
this.comboBox1.FlatStyle = FlatStyle.Flat;
Or in the designer:
This is the result:
However, if you want to add more extra features, it's advisable to create your own component, which would be a little bit more complicated.
I'm scratching my head over this one. I know how to set the background of a cell -- pretty straight-forward, but a new requirement that has come down is that the BORDER cannot be changed.
So, normally if I wanted to set the cell's background, I'd do something like...
var interior = someCell.Interior;
interior.Color = someColor;
That works, but the borders change as well. The idea is to change only the actual "background" of the cell. I tried using the PatternColor property on interior as well with Pattern = XlPatternSolid, also to no avail.
Is there a good way to do this, such that we ONLY change the background color -- not the borders?
I'm making "something" (I don't know how to define it yet), and what does is create a pptx presentation and some slides... but I'm facing some problems: I can't change the background color/image of my slides and textboxes... and I can't figure it out... Can anyone help me?
The thing you are probably missing with regards to setting colors of objects on your slides is that COM Interop thinks about colors slightly differently than what you may be used to in the .NET Framework.
In the .NET Framework, we represent colors using the aptly-named Color structure, which encapsulates values for the alpha channel of the color, and its red, green, and blue components. However, COM Interop represents colors as an Integer value, in the format BGR. That means that the component values for red, green, and blue are actually stored as blue, green, and red.
However, the .NET Framework provides an easy, built-in way to convert between these two color formats: the ColorTranslator.ToOle and ColorTranslator.FromOle methods. So, you should be able to change the background color of your PowerPoint slide using the following code:
//Create a color
Color myBackgroundColor = Color.LimeGreen;
//Translate to an OLE color
int oleColor = ColorTranslator.ToOle(myBackgroundColor);
//Set the background color of the slide
mySlide.Background.Fill.ForeColor.RGB = oleColor;
Conversely, to retrieve the current background color as a .NET color, you'll have to do the opposite:
//Get the current background color of the slide
int oleColor = mySlide.Background.Fill.ForeColor.RGB;
//Translate to a .NET Color
color myBackgroundColor = ColorTranslator.FromOle(oleColor);
And, of course, if you want to set the foreground (fill) color of a shape, you can simply set its ForeColor property, like so:
//Create a color
Color myForegroundColor = Color.Aqua;
//Translate to an OLE color
int oleColor = ColorTranslator.ToOle(myForegroundColor );
//Set the foreground color of a shape
myShape.Fill.ForeColor.RGB = oleColor;
I was having the same issue until I discovered that you need to set slide.FollowMasterBackground to false:
Slide slide = presentation.Slides.AddSlide(presentation.Slides.Count + 1, layout);
slide.FollowMasterBackground = Microsoft.Office.Core.MsoTriState.msoFalse;
slide.Background.Fill.ForeColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DarkBlue);
I figured it out... in order to change the background of a slide u must first call the method Fill.Background() before changing the color/picture!!! tks everyone for the help