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


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

Posted on 2006-03-22
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 ?

Question by:John500
LVL 12

Expert Comment

ID: 16265693
There is a article talking about VB.NET. Wish it is helpful to you as well.
Creating Visual Basic .NET Controls from Scratch
LVL 22

Expert Comment

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


Author Comment

ID: 16269550
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 45

Expert Comment

ID: 16272197
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.

Author Comment

ID: 16275553

>> 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 !

Author Comment

ID: 16276188

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 ?


Accepted Solution

SmithJW earned 500 total points
ID: 16277934
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.
LVL 45

Assisted Solution

AndyAinscow earned 500 total points
ID: 16278053
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).

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

873 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