473,511 Members | 15,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to store button color

1 New Member
I want my buttons to change color on focus and then go back to the color they were when they lose focus. The buttons have different colors so I want to store the color they were before and then have it go back to that color. Here is the code I currently have:

Expand|Select|Wrap|Line Numbers
  1.     class SSButton : System.Windows.Forms.Button
  2.     {
  3.         protected override void OnGotFocus(EventArgs e)
  4.         {
  5.             this.BackColor = bc;
  6.             BackColor = Color.FromArgb(206, 225, 253);
  7.             base.OnGotFocus(e);
  8.         }
  9.         protected override void OnLostFocus(EventArgs e)
  10.         {
  11.             BackColor = bc;
  12.             base.OnLostFocus(e);
  13.         }
  14.         public Color bc { get; set; }
  15.     }
  16.  
This changes the button backcolor but when it looses focus it is changing to the backcolor of the form not to the previous backcolor. How do I get it to change to the previous backcolor and not the form backcolor?
Sep 3 '10 #1
1 936
Sfreak
64 New Member
Why dont you save the previous color in a variable and recover when the button lose focus?
Sep 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9184
by: jullag | last post by:
Hi everyone, this was originally posted to a javascript group. If indeed there is no standard, is there a way to do it SPECIFICALLY for firefox? anyone can help? thanks! j jullag wrote:
1
1479
by: tshad | last post by:
I want to be able to change the color of the text of a button after it is pressed. The first part of the event is: sub submitQuestion_click(Sender as Object, e as EventArgs)...
3
5561
by: Dave Wurtz | last post by:
Can anyone tell me how to get the current color of a combobox's button? I have a custom control that I want to look similar to a combobox. It contains a button control that I want to look like the...
1
1634
by: Bob Greschke | last post by:
I have a GUI where the background of the "GO" button, for example, turns green while the associated action is running. On Windows it works fine, but on Solaris and Linux the button background...
0
1576
by: slinky | last post by:
Does anyone know how I can get the following code finished. I'm trying to dreate a onmouseover event to change the color of a button. Here's my .vb: ( I included other code for the button...
4
9843
by: shelendramalik | last post by:
how can be change fileupload browse button color in javascript. thanks shelendra malik
0
899
by: id10t error | last post by:
Hello, I am making an ASP.NET page to run on a handheld scanner. The screen is pretty small and when you use the tab button to move from button it is hard to tell what button the tab index is...
2
12384
by: dangerouskicker | last post by:
dear friends any one can guide me or help, How i can change checkbox and radio button color change with java script regards devang
1
3031
by: daydreaming | last post by:
Hi All, I would like to know is there any way to set the color of the button in drop-down menu. Below is the sample HTML object (select) that I would like to set its button color. <html>...
0
7242
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
7418
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
5662
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,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.