Weird grey background on checkbox - c#

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.

Related

How to DISABLE transparency for TextView in GTK#?

I am making a GTK# application and I have some weird behavior with TextView (or perhaps ScrolledWindow, can't really tell):
It's basically copying whatever's behind it and using it as the background, when the background should be a solid color. When I switch tabs, it even displays what was in the previously selected tab.
How do I fix this behavior?
Well, I didn't like that I had to do it this way, but it works:
// Fix the weird display bug
drawnHandler = new DrawnHandler((o, args) =>
{
this.Drawn -= drawnHandler;
var color = ConsoleBox.StyleContext.GetBackgroundColor(StateFlags.Normal);
ConsoleBox.OverrideBackgroundColor(StateFlags.Normal, new Gdk.RGBA()
{
Red = color.Red,
Green = color.Green,
Blue = color.Blue,
Alpha = 1
});
});
this.Drawn += drawnHandler;
This gets the proper background color and sets it without alpha (which I'm not even sure how the alpha was set in the first place since I never changed the background color anywhere in the code).

Changing form color depending on answer

I have searched, and tried answers. I have the code, but I'm unsure why it isn't working. I am trying to change the backcolor of the form from green back to white. I believe I have it correct, but it doesn't show the first color, only the last.
if (PassBox1.Text == PassBox2.Text)
{
this.BackColor = Color.FromArgb(0, 255, 0);
// voice.Speak("Correct ", SpeechVoiceSpeakFlags.SVSFDefault);
this.BackColor = Color.FromArgb(192,192,192);
}
When this code runs and backcolor is set to (0,255,0) which is followed by a blocking operation voice.speak, this does not give chance to the ui to refresh and soon as voice speak is done, the backcolor changes to (192...) before ui gets changes to show the other color.
in this case you would be much happier if you created a subclassed text box which allows you to flash colors. you can use some ideas from this post
https://stackoverflow.com/a/4147406/2903863

Winforms combobox background

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.

How to change multiple label's text color at the same time in Xamarin Forms?

I have multiple Labels inside a Grid which are places in different grid rows and columns. I want to change all the label's font color into just one color whenever I select a different theme color in my settings. At the moment I have the following code in C#:
correctLabel.TextColor = Color.Black;
textLabel.TextColor = Color.Black;
emptyLabel.TextColor = Color.Black;
detail1.TextColor = Color.Black;
detail2.TextColor = Color.Black;
detail3.TextColor = Color.Black;
As you can see, this code could be longer if I decided to add more Labels. Is there a way to do this in one line?
Your question is already leading to the right assumption, you shouldn't do it per view element.
If you are able to use the 2.3 preview, there's built-in support for themes, check out the docs.
Prior to 2.3 pre you can use ControlTemplates, a nice sample can be found here.
Edit: If you're not aiming to theme the whole app, you can bind to a color in your view model of you are familiar with that and by changing that color, the label colors would adapt it. I guess maybe that comes closer to the one-line approach.

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.
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.

Categories

Resources