[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Standard Button, how to change the style and apperance, ie press button, light goes on and press button light goes off

Posted on 2005-04-05
Medium Priority
Last Modified: 2010-04-16
I have several standard button and would like change style into instrument type that has yellow/green LED build in.

What is required to change the button so that when pushed, it selected and the imaginary LED goes ON and if unslected goes OFF. At the moment I using button.background=color.lightgreen property.

I can make custom button style from the paint, should this be icon type or paint type?. There are about 15 button with different names written on it, is array better to handle different button?.

Question by:riscy

Accepted Solution

RomanPetrenko earned 1000 total points
ID: 13714175
If you want button with LED on it:

You can use 2 images(LED on and LED off) to set them on image property of button.
public class LEDButton: Button
public static Image LEDOn = Image.FromFile(@"c:\ledon.bmp");
public static Image LEDOff = Image.FromFile(@"c:\ledoff.bmp");
public LEDButton()
      base.Image = LedState ? LEDOn : LEDOff;
      base.ImageAlign = ContentAlignment.MiddleLeft; //LED will be in the middle on the left side of the button.
private bool LedState = false;//Led by default is off
protected override void OnClick(EventArgs e)
      LedState = !LedState;
      base.Image = LedState ? LEDOn : LEDOff;
      base.OnClick (e);
====End of sample====

if you want button looks LIKE LED
use instead picturebox with LED images and switch them on click event.

Author Comment

ID: 13714218
That is very quick....I have to work overtime but thank!!!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question