We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


How to add a 'light' to my .Net Form Application -> does the toolbox provide simple lights i.e. red/green

John500 asked
Medium Priority
Last Modified: 2010-04-24

I have a .Net Form App and I want to add two lights which will signify a GO/NO-GO status.

After looking through all the options on the toolbox, I didn't see anything that seemed to fit the bill.

How can I incorporate such a thing and what is the exact code to turn such lights on with the appropriate color ?

Watch Question

There is a article talking about VB.NET. Wish it is helpful to you as well.
Creating Visual Basic .NET Controls from Scratch
mahesh1402IT Professional
Top Expert 2005

and also a LED control in C# here may help :http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c4793/



Thanks to both of you, but this won't work for me.  I'm looking for direct references to Visual C++ .Net toolbox objects and some sample code C++ code
AndyAinscowFreelance programmer / Consultant

Two icons - one red, one green.
Use two times picture control, one for each icon.
For go hide the red picture and show the green, you get the idea.



>> Two icons - one red, one green.

I'm not as versed in such things as you might expect.  How would I create an icon from scratch?  After that I'm guessing the properties of the icon would allow me to set a default color.  If so, I'd need to know how to change that color during run-time.  Lastly, I would prefer the icon to be round rather than square.  The more I think about it, I don't need two, just one that can change from red to green.

Thanks !



I guess I'm not as bad as I thought I was.  I created a round red icon and a green one also from 'Paint'.  I saved them as icons and then imported them into my project's GroupBox as pictureBoxes.  

What did you mean by 'two times picture control' ?  Are you saying I should put one picture on top of the other and then show which ever one I want depending upon the status?  In any event, these objects are called pictureBox1 and pictureBox2.  What would the code look like to display them ?

You're on the right lines so far with the 2 picture boxes.
Assuming PictureBox 1 is 'green', and ValidInput is  a bool, set by a Validation function:

if ( ValidInput == true )
   PictureBox1.visible = true;
   PictureBox2.visible = false;
   PictureBox1.visible = false;
   PictureBox2.visible = true;

obviously replace ValidInput with whatever condition you want to check, but this will get you going for now.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
AndyAinscowFreelance programmer / Consultant
In the resource editor of visual studio you can create icons.
Put a picture box control onto your form and you should be able to select the type of picture as icon and the ID (of the icon you just created).  Now you have one picture control with for instance a red circle in it.  Do the same to create a second, green, icon.  Add a second picture control and link the picture control to the icon.
Now all you need to do is toggle the visible state of the control depending on which icon you want to display.

You need two picture controls because each contains one image.  (You could do it with one control and swap the images but using two controls and visibility is simpler to code).
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.