default button gray color

P

Peted

I have a winform in c#, with some default buttons.
The default face color of these buttons is a nice shade of light grey,
basicly the default button color you see on ms apps.

I want the button to go color red when it is depressed and return to
the nice grey shade it has when it is up

i know how to change the colors, but i cant find in Colors or in
SystemColors the correct shade of grey.

What is it ? If i use the Systemcolors.Control or buttonface greys,
they are not the color im looking for

Im thinking its a grey from XP user preferences for each pc, how can i
set it back to this ?


thanks for any help

Peted
 
P

Peted

On Wed, 02 May 2007 11:14:29 +0800, Peted wrote:

Let me correct slightly what i posted, im using check boxs with the
appearence set to "button", but i still have the problem bellow

thanks

Peted
 
J

jblivingston

i know how to change the colors, but i cant find in Colors or in
SystemColors the correct shade of grey.
In my opinion, you would be better off preserving the up color and
restoring it rather than hard-coding it in multiple places. On a form
that you have defined event handlers for both the MouseUp and
MouseDown events, you can do something similar to the following:

Color upColor;
Color downColor = Color.Red;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
Button button = sender as Button;
this.upColor = button.BackColor;
button.BackColor = this.downColor;
}

private void button1_MouseUp(object sender, MouseEventArgs e)
{
button1.BackColor = this.upColor;
}

thanks for any help

I hope my suggestions were helpful.

John

P.S. This tactic will work with most controls
 
P

Peted

On 1 May 2007 21:05:14 -0700, (e-mail address removed) wrote:

Hi thanks for your help.

the technique you show here is more efficient to what i was doing,
however it still has the same problem.

The color that is restored on the "up" is not the same light grey
shade of the button face, before the button was clicked. The grey is
darker same as the form background

The only thing i can think of is that the "use visualstyles" options
are not overriding the color of the button, like they should

any ideas would be helpfull

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top