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
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
    LVL 8

    Accepted Solution

    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

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    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!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now