473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

default button gray color

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
May 2 '07 #1
3 15241
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
>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
May 2 '07 #2
On May 1, 11:14 pm, Peted wrote:
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

May 2 '07 #3
On 1 May 2007 21:05:14 -0700, jb**********@gmail.com 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


>On May 1, 11:14 pm, Peted wrote:
>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
May 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lyle H. Gray | last post by:
We load a table from a text file using Data Transformation Services. The source file is already sorted by primary key order. After the DTS load, the default retrieval order on the target table...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
0
by: Benny Raymond | last post by:
I have a list view and a button that turns the currently selected item's ForeColor to SystemColors.GrayText The problem I'm having is that when the user clicks in white space, the item becomes...
4
by: JC Voon | last post by:
Hi: My application use tabbed interface, i need a close button at the right edge of the tool bar, is it possible ? Thanks JCVoon
2
by: Martijn Mulder | last post by:
I want my buttons to look like and behave like the 'Tools' in, for example, MSPaint. The border of the button is invisible, the image just 'hangs' in the gray background. When the mouse pointer is...
12
by: Doogie | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself,...
5
by: Zytan | last post by:
In the IDE, I changed the BackColor of a button. Then, I changed it back to what I thought was the default, 'Control'. But, the bolded text didn't disappear (I think bold means the setting is not...
6
by: blaine | last post by:
Hello, I'm currently overriding function keys (F1 to F4) to perform other actions. In order to do this the default popup windows of Help (F1), Seach(F3) etc must be turned off. In FF it's easy...
5
by: perhapscwk | last post by:
I have something like below, normally when my mouse is over the button, it will change from less visible to visible, if mouse move away, it turn back to less visible. But now i want to make it...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.